refiking Posted August 24, 2007 Share Posted August 24, 2007 How can I redirect this page after I store the data into the database? Here is the entire script: <?php session_start(); include 'connect.php'; $lcid=$_POST['lc_id']; $password=$_POST['lcpass']; $id = mysql_query("SELECT password FROM lreps WHERE lc_id = '$lcid'"); $fetch_em = mysql_fetch_array($id); $numrows = mysql_num_rows($id); IF($numrows != "0" & $password == $fetch_em["password"]) { $result = mysql_query("SELECT * FROM CP"); $num = mysql_num_rows($result); $lead_id = $num + 1; echo $lead_id; mysql_query("INSERT INTO `CP`(lc_id , lead_id , bfn , bln , bdob, bssn, cfn , cln , cssn, addy, zip , rty, rtime, tenure, value, bemp, bjt, bjten, bb1, bb1a, bb2, bb2a, bb3, bb3a, cemp, cjt, cjten, cb1, cb1a, cb2, cb2a, cb3, cb3a, taxes, ins) VALUES('$lcid','$lead_id','$bfn','$bln','$brdob','$brssn','$cfn','$cln','$cssn','$addy','$zip','$response','$rptime','$ten', '$value','$bremp','$brjt','$brjhist','$bb1','$bb1a','$bb2','$bb2a','$bb3','$bb3a','$cemp','$cjt','$cjhist','$cb1','$cb1a','$cb2', '$cb2a','$cb3','$cb3a','$taxes','$ins')")or die(mysql_error()); Print "This lead was succesfully entered into the system."; // If it's desired to kill the session, also delete the session cookie. // Note: This will destroy the session, and not just the session data! if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time()-42000, '/'); } // Finally, destroy the session. session_destroy(); ?> <html> <head><title>1003 App</title></head> <body> <h2>Data Collection</h2><p> <form action="app1.php" method="post"> <table> <tr><td>Phone Number:</td><td><input type="text" name="Phone" /></td></tr> <tr><td colspan="2" align="center"><input type="submit" value="Next" /></td></tr> </table> </form> </body> </html> <? } ELSEIF ($numrows == "0") { ?> <html> <head><title>1003 App</title></head> <body> <h2>ID and Password Failure: Please re-enter.</h2><p> <form action="loanappsave.php" method="post"> <table> <tr><td>Loan Consultant ID:</td><td><input type="text" name="lc_id" /></td></tr> <tr><td>Password:</td><td><input type="text" name="lcpass" /></td></tr> <tr><td colspan="2" align="center"><input type="submit" value="Next" /></td></tr> </table> </form> </body> </html> <? } ELSEIF ($password != $fetch_em["password"]) { ?> <html> <head><title>1003 App</title></head> <body> <h2>ID and Password Failure: Please re-enter.</h2><p> <form action="loanappsave.php" method="post"> <table> <tr><td>Loan Consultant ID:</td><td><input type="text" name="lc_id" /></td></tr> <tr><td>Password:</td><td><input type="text" name="lcpass" /></td></tr> <tr><td colspan="2" align="center"><input type="submit" value="Next" /></td></tr> </table> </form> </body> </html> <? } ?> And this is the line that I am talking about specifically: Print "This lead was succesfully entered into the system."; // If it's desired to kill the session, also delete the session cookie. // Note: This will destroy the session, and not just the session data! if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time()-42000, '/'); } // Finally, destroy the session. session_destroy(); ?> <html> <head><title>1003 App</title></head> <body> <h2>Data Collection</h2><p> <form action="app1.php" method="post"> <table> <tr><td>Phone Number:</td><td><input type="text" name="Phone" /></td></tr> <tr><td colspan="2" align="center"><input type="submit" value="Next" /></td></tr> </table> </form> </body> </html> <? } Instead of trying to add the HTML code, I want to just redirect to app.php Quote Link to comment https://forums.phpfreaks.com/topic/66521-redirect-page/ Share on other sites More sharing options...
obsidian Posted August 24, 2007 Share Posted August 24, 2007 Check out the header() function in the manual: <?php header("Location: app.php"); exit(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/66521-redirect-page/#findComment-333100 Share on other sites More sharing options...
drewbee Posted August 24, 2007 Share Posted August 24, 2007 use header("Location: /placewhereiwanttogo.php"); Below this line add it: <? // Finally, destroy the session. session_destroy(); header("Location: /placewhereiwanttogo.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/66521-redirect-page/#findComment-333104 Share on other sites More sharing options...
refiking Posted August 24, 2007 Author Share Posted August 24, 2007 Warning: Cannot modify header information - headers already sent by (output started at /home/refiking/public_html/apps/loanappsave.php:13) in /home/refiking/public_html/apps/loanappsave.php on line 24 Warning: Cannot modify header information - headers already sent by (output started at /home/refiking/public_html/apps/loanappsave.php:13) in /home/refiking/public_html/apps/loanappsave.php on line 29 Line 23-25: if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time()-42000, '/'); } Line 29: header("Location: /app.php"); Quote Link to comment https://forums.phpfreaks.com/topic/66521-redirect-page/#findComment-333124 Share on other sites More sharing options...
drewbee Posted August 24, 2007 Share Posted August 24, 2007 You need to make sure the header call happens before any output is sent to the browser. Headers are sent before the html is rendered out to the browser, thus needing it set before this action happens. In your code above, you have several echo's. Remove them or rearrange things as to not output data so that the header can be set. Quote Link to comment https://forums.phpfreaks.com/topic/66521-redirect-page/#findComment-333319 Share on other sites More sharing options...
refiking Posted August 24, 2007 Author Share Posted August 24, 2007 Just a session start and an include of my connect.php page. Quote Link to comment https://forums.phpfreaks.com/topic/66521-redirect-page/#findComment-333322 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.