SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: php header

  1. #1
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    php header

    Greetings!

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

    here is my html code.
    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 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.

  2. #2
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,806
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    Try this:

    PHP Code:
    <?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

  3. #3
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2011
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try the full url instead of relative url, like this:
    header("Location: http://yourdomain.com/Book_new2.php");

  5. #5
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    I'm using frameset. I think its not possible.

  6. #6
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •