prawn_86 Posted March 14, 2009 Share Posted March 14, 2009 Hi all, Simple question, i just cant quite figure out where i need to put the line of code (Im new). I want to echo to a page wqhen my users submit the form. Here is the PHP codes i have on my page. Where would i put the echo statement, for a page called process.html? <?php //process any requests they have sent if (isset($_GET['submit']) && $_GET['submit'] == true){ $title = mysql_real_escape_string($_POST['title']); $url = mysql_real_escape_string($_POST['url']); $sql = "INSERT INTO `test_table` VALUES('', '$title', '$url');"; mysql_query($sql); } ?> <?php $sql = "SELECT excluded_word FROM `word_exclusion_table`"; $result = mysql_query($sql); $whereclause = ""; while ($row = mysql_fetch_assoc($result)){ $whereclause .= (($whereclause) ? ' AND ' : ' WHERE ')."title NOT LIKE '%".$row['excluded_word']."%' "; $whereclause .= (($whereclause) ? ' AND ' : ' WHERE ')."url NOT LIKE '%".$row['excluded_word']."%' "; } //time to show you what you have in the database $sql = "SELECT * FROM `test_table` $whereclause ORDER BY `id` DESC LIMIT 5000;"; $result = mysql_query($sql); print " <table border=\"0\">\n"; while ($row = mysql_fetch_assoc($result)){ $title = $row['title']; $url = $row['url']; echo " <tr> <td><a href=\"$url\" target=\"http://www.freefreeads.com\">$title</a></td> </tr> "; } print " </table>\n"; ?> Quote Link to comment Share on other sites More sharing options...
Akenatehm Posted March 14, 2009 Share Posted March 14, 2009 You might want to auto redirect them when they submit the form. YOu can do it like this: <?php header("Location: process.html"); ?> At the bottom of your script. Hope that's what you wanted. Quote Link to comment Share on other sites More sharing options...
prawn_86 Posted March 14, 2009 Author Share Posted March 14, 2009 do i put that under the print function in my second script in the OP? I tried that but it didnt work, i must be missing something. Sorry for the simple question... Quote Link to comment Share on other sites More sharing options...
Akenatehm Posted March 14, 2009 Share Posted March 14, 2009 Explain what you are trying to do with each script and what you want it to do. Then I can help better. Quote Link to comment Share on other sites More sharing options...
prawn_86 Posted March 14, 2009 Author Share Posted March 14, 2009 Basically i want to redirect them to a different page (process.html or whatever title, not important) once they have clicked submit. It will be a thankyou page essentially. Quote Link to comment Share on other sites More sharing options...
Akenatehm Posted March 14, 2009 Share Posted March 14, 2009 Which script is doing what? Are they on the same page? Quote Link to comment Share on other sites More sharing options...
prawn_86 Posted March 14, 2009 Author Share Posted March 14, 2009 The top script is in the header, the second one is in the body as part of the form. Both on the same page The top script inserts the values into the table, and the second script displays the values (minus the banned ones) on my page. Quote Link to comment Share on other sites More sharing options...
Akenatehm Posted March 14, 2009 Share Posted March 14, 2009 <?php while ($row = mysql_fetch_assoc($result)){ $title = $row['title']; $url = $row['url']; echo " <tr> <td><a href=\"$url\" target=\"http://www.freefreeads.com\">$title</a></td> </tr> "; } print " </table>\n"; echo "yourlink.html"; //Put it here. ?> Quote Link to comment Share on other sites More sharing options...
prawn_86 Posted March 14, 2009 Author Share Posted March 14, 2009 That still didnt work, i think i have tried that before. The page that loads when somethiing is submitted, even with that echo statement is: http://www.freefreeads.com/?submit=true Thanks for your help so far... Quote Link to comment Share on other sites More sharing options...
prawn_86 Posted March 29, 2009 Author Share Posted March 29, 2009 Any further help with this? I still cant get it working Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 29, 2009 Share Posted March 29, 2009 what about this then. <?php while ($row = mysql_fetch_assoc($result)){ $title = $row['title']; $url = $row['url']; echo " <tr> <td><a href=\"{$_SERVER['PHP_SELF']}?cmd=go\">$title</a></td> </tr> "; } print " </table>\n"; if(isset($_GET['cmd'])&& $_GET['cmd']=="go"){ header("location: where_ever.php"); exit; } ?> Quote Link to comment Share on other sites More sharing options...
prawn_86 Posted March 29, 2009 Author Share Posted March 29, 2009 Thanks redarrow, but that doesnt work either, gives a sytax error "unexpected $end". Man who would have thought it would be so hard just to do a simple redirect Quote Link to comment Share on other sites More sharing options...
killah Posted March 29, 2009 Share Posted March 29, 2009 <?php while ($row = mysql_fetch_assoc($result)){ $title = $row['title']; $url = $row['url']; echo " <tr> <td><a href=\"{$_SERVER['PHP_SELF']}?cmd=go\">$title</a></td> </tr> "; } print " </table>\n"; if(isset($_GET['cmd']) && $_GET['cmd']=="go"){ header("location: where_ever.php"); exit; } ?> Try that. Quote Link to comment Share on other sites More sharing options...
prawn_86 Posted March 29, 2009 Author Share Posted March 29, 2009 Still not working Killah ??? Page works properly now, but the redirect just doesnt happen, still goes to http://www.freefreeads.com/?submit=true that page every time Quote Link to comment Share on other sites More sharing options...
prawn_86 Posted April 3, 2009 Author Share Posted April 3, 2009 Any other help out there? im thinking i need to change the fact that it links to page http://www.freefreeads.com/?submit=true but none of the php i have tried so far works ??? Quote Link to comment Share on other sites More sharing options...
prawn_86 Posted April 5, 2009 Author Share Posted April 5, 2009 bump... please? Quote Link to comment Share on other sites More sharing options...
prawn_86 Posted April 5, 2009 Author Share Posted April 5, 2009 Ok so i can now get it to go to the page i want when someone adds something into the form, but it now does not display on my homepage. Any ideas? Quote Link to comment 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.