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"; ?> Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/ 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. Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-784383 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... Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-784386 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. Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-784388 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. Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-784391 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? Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-784393 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. Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-784396 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. ?> Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-784400 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... Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-784401 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 Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-796049 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; } ?> Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-796169 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 Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-796429 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. Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-796431 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 Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-796433 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 ??? Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-800019 Share on other sites More sharing options...
prawn_86 Posted April 5, 2009 Author Share Posted April 5, 2009 bump... please? Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-801468 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? Link to comment https://forums.phpfreaks.com/topic/149350-simple-echo/#findComment-801566 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.