Php header

Greetings!

I have here code that simply send input using mootols.js

here is my html code.


<html>
<head>
<title>Book Acquisition</title>
<script type="text/javascript" src="../js/mootools.js"></script>
<script type="text/javascript">
		window.addEvent('domready', function(){
	                $('registerForm').addEvent('submit', function(e) {
	                    new Event(e).stop();
	                    var log = $('log_res').empty().addClass('ajax-loading');
	                    this.send({
	                        update: log,
	                        onComplete: function() {
	                            log.removeClass('ajax-loading');
								
	                        }
	                    });
	                });
	            });
</script>
<body>

<form id ="registerForm"  action = "act1.php" method = "post">
<p><strong><label>Book Title:</label></strong><input type="text" name = "Title" placeholder = 'Title' required></p>

</form>
<div id="log">
		<div id="log_res">
		<!-- SPANNER -->
		</div>
		</div>
</body>
</html>

My problem is, I want to redirect when my validations is successful. I’m using my php code.


<?php include'../connection/connect-db.php';

	 $Title = $_POST['Title'];
	
	 if (empty($Titles)) {
		echo 'title is empty';
	}else {	
	
	 sql queriess..
	 saving successful..
	 header("Location: Book_new2.php");
	 }
	 ?>

My problem is when my validation is successful it doesn’t redirect to my header. Its not working.
Any help.

Try this:


<?php include'../connection/connect-db.php'; 
  
     $Title = $_POST['Title']; 
      
     if (empty($Titles)) {  
        echo 'title is empty'; 
    }else {     
     
     sql queriess.. # OK as long as thee is no echo ...

     header("Location: Book_new2.php"); 
    echo 'saving successful.. ':

// ?> # not required

Thank you for the response.

The result is shown on the same page. Is there any way to redirect it to another page?
Although in the same frame.

Try the full url instead of relative url, like this:
header(“Location: http://yourdomain.com/Book_new2.php”);

I’m using frameset. I think its not possible.

I don’t understand why php is acting like this.
I tried this code like a thousand times earlier but now it works.

echo ‘<META http-equiv=“refresh” content=“0;URL=Book_new2.php” >’;

Thank you anyway.