Regarding redirect page in php

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
saran_tvmalai
Forum Newbie
Posts: 5
Joined: Fri Sep 19, 2008 7:42 am

Regarding redirect page in php

Post by saran_tvmalai »

hi all,
the below file name is saran.php

Code: Select all

 
[b]<form action="insert.php" method="post" name=" ">
Email Id  <input type="text" name="emailid" /><br>
ResiPhone No  <input type="text" name="resph" /><br>
Office Ph  <input type="text" name="offph" /><br>
Mobile No  <input type="text" name="mobile" /><br>
<input type="submit" />
</form>[/b]
 
And the insert.php is

Code: Select all

 
<?php
 
$con = mysql_connect('localhost','root','');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("mydb", $con);
 
$sql="INSERT INTO los_master_detail (email,phone,resphone,mobile)
VALUES
('$_POST[email]','$_POST[phone]','$_POST[resphon]','$_POST[mob]')";
 
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
 
  echo("<SCRIPT LANGUAGE='JavaScript'>
window.alert('1 Record Has Been Updated')
</SCRIPT>");
 
mysql_close($con)
?>

And after the record update the message box is enable. i need if i click the message box ok button it redirect to saran.php.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Regarding redirect page in php

Post by Christopher »

Use Javascript to check the return value of the alert and redirect.
(#10850)
ramya123
Forum Newbie
Posts: 13
Joined: Thu Sep 11, 2008 6:11 am

Re: Regarding redirect page in php

Post by ramya123 »

Place this line of code
window.location.href="saran.php";

after
window.alert('1 Record Has Been Updated')
Post Reply