Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: PHP redirection

  1. #1
    Regular Coder
    Join Date
    May 2007
    Location
    Indonesia
    Posts
    164
    Thanks
    10
    Thanked 0 Times in 0 Posts

    PHP redirection

    Need help urgently on PHP project that Im working on. This is for my work and I've been instructed to develop a website/blog. I've got the website up and running and everything however I would like it to redirect to the messageboard after a message has been posted from a form. Sort of like what codingforums has after logging in, it will redirect to the page where messages can be posted. How can this be accomplished using php or is JavaScripted needed for this. Any help appreciated.

  • #2
    New Coder
    Join Date
    Apr 2008
    Location
    Blagoevgrad, Bulgaria
    Posts
    47
    Thanks
    0
    Thanked 8 Times in 8 Posts
    PHP Code:
    header("refresh: 3; url=wheretoredirect"); 
    That will redirect you after 3 seconds, to wheretoredirect (change this to your page).

  • #3
    Regular Coder
    Join Date
    May 2007
    Location
    Indonesia
    Posts
    164
    Thanks
    10
    Thanked 0 Times in 0 Posts
    ok will give it a shot and let you know if it works,thx

  • #4
    Regular Coder
    Join Date
    May 2007
    Location
    Indonesia
    Posts
    164
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Hey bud is this right way?
    Code:
    header("refresh: 3; url=message_board.php");
    <?php // Script 12.5 - add_entry.php
    // This script adds an entry to the database.
    
    // Address error handing.
    ini_set ('display_errors', 1);
    error_reporting (E_ALL & ~E_NOTICE);
    
    if (isset ($_POST['submit'])) { // Handle the form.
    
    	// Connect and select.
    	if ($dbc = @mysql_connect ('localhost', 'postc3', 'jesy+qrp')) {
    		
    		if (!@mysql_select_db ('msgboard')) {
    			die ('<p>Could not select the database because: <b>' . mysql_error() . '</b></p>');
    		}
    	
    	} else {
    		die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b></p>');
    	}
    	
    	
    	// Define the query.
    	$query = "INSERT INTO entry (name, message, date) VALUES ('{$_POST['from']}', '{$_POST['message']}', NOW())";
    	
    	// Execute the query.
    	
    
    
             if (@mysql_query ($query)) {
    		print '<p>The message has been added.</p>';
             
    
    
    	} else {
    		print "<p>Could not add the message because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
    	}
    
          
    
    	mysql_close();
    
    } 
    
    // Display the form.
    ?>
    <form action="form.php" method="post">
    <p>From: <input type="text" name="from" size="40" maxsize="100" /></p>
    <p>Message: <textarea name="message" cols="40" rows="5"><?php 
             $message = $_GET['msg']; 
             if(isset($message))
                print "Enter your message here:&nbsp;";
        ?></textarea></p>
    <input type="submit" name="submit" value="Submit"  /></form>
    </body>
    </html>

  • #5
    Regular Coder
    Join Date
    May 2007
    Location
    Indonesia
    Posts
    164
    Thanks
    10
    Thanked 0 Times in 0 Posts
    It didn't work corrected the code by placeing php tags around the code u supplied but it hust stays on the same form still

    the website can be viewed at www.postcardsfromheaven.co.nz

  • #6
    Regular Coder
    Join Date
    May 2007
    Location
    Indonesia
    Posts
    164
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks got it going


  •  

    Posting Permissions

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