Jump to content

Site not displaying input


prawn_86

Recommended Posts

Hi All,

 

I have my site: www.freefreeads.com

 

I am updating it to make it harder for spammers to utilise. My problem is that when a user enters something in the form, it does not display on the homepage like i want it to, it doesnt even make it to my database for some reason.

 

Here is the code i have so far:

 

On homepage-

<?php
$database_user = "***"; //user for the database
$database_password = "****"; //password for the user listed above
$database_name = "***"; //the name of the database
$database_host = "localhost"; //You prolly won't need to change this one.

$link = mysql_connect($database_host, $database_user, $database_password);
mysql_select_db($database_name, $link);

?>

<?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";
;

?>


<?php
mysql_close($link);
?>

 

On process page -

<?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);
}
?>

 

Im fairly sure its something going wrong with my code on the process page due to it not making it to the database, and the homepage still displaying everything which is currently in the database.

 

Please help...

Link to comment
https://forums.phpfreaks.com/topic/154320-site-not-displaying-input/
Share on other sites

You're checking to see if a $_GET submit button was clicked and your insert is expecting $_POST data. The only way this would work is if your form has an action of "?submit=blah".

 

Also, if $_GET['submit'] is set it will be a string so strictly speaking will never === true. If you've set the submit button value to "true" then you ought to check for $_GET['submit'] == "true".

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.