Hello, below is a page i'm using to update my database (mysql). Everything works perfect, except i dont know where to include this statement ( header("Location: http://rushhourdirect.com/rushhour/trafficadmin/create_record.php"); ) so that the page redirects to another page instead of just refereshing it's self.
Below is the complete code i'm using for the page. I would appreciate your help in finding where the redirect statment would go. (I've tried many times, but it doesn't redirect at the right time. The page needs to redirect after the "update" button is hit")
<?php
if ( isset($mybutton) ) {
$user = "scallywa";
$pass = "Sa11yg53";
$db = "loopbiz_com";
$found = false;
$link = mysql_connect( "localhost", $user, $pass );
if ( ! $link ) die( "Couldn't connect to MySQL" );
mysql_select_db( $db ) or die ( "Couldn't open $db: ".mysql_error() );
if ($mybutton == "search") {
$query = "SELECT id, name, url, email FROM rhd_traffic where name = \"$name\" ";
$result = mysql_query( $query, $link) or die ( "Couldn't select from \"rhd_traffic\" tables: " . mysql_error() );
if ($cols = mysql_fetch_array($result) ) {
$id = $cols[0];
$name = $cols[1];
$url = $cols[2];
$email = $cols[3];
$found = true;
}
}
if ($mybutton == "update") {
$query = "UPDATE rhd_traffic SET name = \"$name\", url=\"$url\", email=\"$email\" where id = \"$id\" ";
mysql_query( $query, $link) or die ( "Couldn't update \"rhd_traffic\" tables: " . mysql_error() );
$found = true;
}
mysql_close( $link );
}
else {
$id = "";
$name = "";
$url = "";
$email = "";
}
?>
<!--
<body>
<form name="form" action="beta_test.php" method="post">
Program Name:
<input type="text" name="name" value="<?php echo $name ?>" size="20">
<br>
Home URL:
<input type="text" name="url" value="<?php echo $url ?>" size="20">
<br>
Email Address:
<input type="text" name="email" value="<?php echo $email ?>" size="20">
<br>
<input type="button" onclick="mybutton.value='search';form.submit()" value="Search">
<?php
if ($found) {
?>
<input type="button" onclick="mybutton.value='update';form.submit()" value="Update">
<?php
}
else {
echo "$name not found";
}
?>
<input type="hidden" name="mybutton">
<input type="hidden" name="id" value = "<?php echo $id ?>" >
</body>
-->