Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-27-2009, 04:45 AM   PM User | #1
rjkdonaldson
Regular Coder

 
Join Date: May 2007
Location: Indonesia
Posts: 163
Thanks: 10
Thanked 0 Times in 0 Posts
rjkdonaldson is an unknown quantity at this point
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.
rjkdonaldson is offline   Reply With Quote
Old 10-27-2009, 04:52 AM   PM User | #2
er4o
New Coder

 
Join Date: Apr 2008
Location: Blagoevgrad, Bulgaria
Posts: 47
Thanks: 0
Thanked 8 Times in 8 Posts
er4o is an unknown quantity at this point
PHP Code:
header("refresh: 3; url=wheretoredirect"); 
That will redirect you after 3 seconds, to wheretoredirect (change this to your page).
er4o is offline   Reply With Quote
Old 10-27-2009, 05:02 AM   PM User | #3
rjkdonaldson
Regular Coder

 
Join Date: May 2007
Location: Indonesia
Posts: 163
Thanks: 10
Thanked 0 Times in 0 Posts
rjkdonaldson is an unknown quantity at this point
ok will give it a shot and let you know if it works,thx
rjkdonaldson is offline   Reply With Quote
Old 10-27-2009, 05:07 AM   PM User | #4
rjkdonaldson
Regular Coder

 
Join Date: May 2007
Location: Indonesia
Posts: 163
Thanks: 10
Thanked 0 Times in 0 Posts
rjkdonaldson is an unknown quantity at this point
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>
rjkdonaldson is offline   Reply With Quote
Old 10-27-2009, 05:11 AM   PM User | #5
rjkdonaldson
Regular Coder

 
Join Date: May 2007
Location: Indonesia
Posts: 163
Thanks: 10
Thanked 0 Times in 0 Posts
rjkdonaldson is an unknown quantity at this point
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
rjkdonaldson is offline   Reply With Quote
Old 10-27-2009, 06:56 AM   PM User | #6
rjkdonaldson
Regular Coder

 
Join Date: May 2007
Location: Indonesia
Posts: 163
Thanks: 10
Thanked 0 Times in 0 Posts
rjkdonaldson is an unknown quantity at this point
Thumbs up

Thanks got it going
rjkdonaldson is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:52 PM.


Advertisement
Log in to turn off these ads.