inquisitive Posted July 6, 2008 Share Posted July 6, 2008 <?php // Pick up the form data and assign it to variables $name= $_Post['name']; $email= $_Post['email']; $topic= $_Post['topic']; $comments= $_Post['comments']; //Build the email (replace the address is the $to section with your own) $to = '[email protected]'; $subject = "New Message: $topic"; $message = "$name said: $comments"; $headers = "From: $email"; //Send the mail using PHPs mail () Function mail($to, $subject, $message, $headers); //Redirect header("location: success.html"); $sql = CREATE TABLE submissions( name VARCHAR(100) NOT NULL, email VARCHAR(255) NOT NULL, topic VARCHAR(255) NOT NULL, comments TEXT NOT NULL ); mysql_query( $sql, $conn ); //Open database connection $conn = mysql_connect('localhost', 'hp_admin', 'portable'); mysql_select_db('contact'); //Insert data $query = "INSERT INTO submissions (name, email, topic, comments) VALUES ('$name', '$email', '$topic', '$comments',)"; mysql_query($query); //close connection mysql_close($conn); //Ioen database connection $conn = mysql_connect('localhost','hp_admin','portable'); //Data cleaning function function clean_data($string) { if (get_magic_quotes_gpc() ) { $string = stripslashes($string); } return mysql_real_escape_string($string); } //Pick up the cleaned for data $name= clean_data($_Post['name']); $email= clean data($_Post['email']); $topic= clean_data($_Post['topic']); $comments= clean_data($_Post['comments']); //Data cleaning function function clean_data($string) { if (get_magic_quotes_gpc()) { $string = stripslashes($string); } $string = strip_tags($string); return mysql_real_escape_string($string); } //Mail header removal function remove_header($string) { $headers = array( "/to\:/i", "/from\:/i", "/bcc\:/i", "/cc\:/i", "/Content\-Transfer\-Encoding\:/i", "/Content\-Type\:/i", "/Mime\-Version\:/i" ); retufn preg_replace($headers, '', $string); } function remove_headers($string) { $headers = array( "/to\:/i", "/from\:/i", "/bcc\:/i", "/cc\:/i", "/Content\-Transfer\-Encoding\:/i", "/Content\-Type\:/i", "/Mime\-Version\:/i" ); if (preg_replace($headers, '', $string) == $string) { return $string; } else { die('You think Im spammy? Spammy how? Spammy like a clown, spammy?'); } } //Mail header removal function remove_headers($string) { $headers == array( "/to\:/i", "/from\:/i", "/bcc\:/i", "/cc\:/i", "/Content\-Transfer\-Encoding\:/i", "/Content\-Type\:/i", "/Mime\-Version\:/i" ); $string = preg_replace($headers, '',string); return strip_tags($string); } //Pick up the cleaned form data $name= remove_headers($_Post['name']); $email= remove_headers($_Post['email']); $topic= remove_headers($_Post['topic']); $comments= remove_headers($_Post['comments']); Link to comment https://forums.phpfreaks.com/topic/113403-t_string-errorposting-my-codeplease-explain-why-this-isnt-working/ Share on other sites More sharing options...
dannyb785 Posted July 6, 2008 Share Posted July 6, 2008 2 errors I caught... retufn preg_replace($headers, '', $string); needs to be 'return' $query = "INSERT INTO submissions (name, email, topic, comments) VALUES ('$name', '$email', '$topic', '$comments',)"; remove the very last comma after the $comments' just before the closing parenthesis Link to comment https://forums.phpfreaks.com/topic/113403-t_string-errorposting-my-codeplease-explain-why-this-isnt-working/#findComment-582662 Share on other sites More sharing options...
inquisitive Posted July 6, 2008 Author Share Posted July 6, 2008 I corrected the above errors and I am getting a T_String error on line 53. I am not sure what this means...because my code looks pretty damn good. anyways...any more help out there? Link to comment https://forums.phpfreaks.com/topic/113403-t_string-errorposting-my-codeplease-explain-why-this-isnt-working/#findComment-583135 Share on other sites More sharing options...
dannyb785 Posted July 7, 2008 Share Posted July 7, 2008 did you even check line 53? You have "clean link", not "clean_link" Link to comment https://forums.phpfreaks.com/topic/113403-t_string-errorposting-my-codeplease-explain-why-this-isnt-working/#findComment-583164 Share on other sites More sharing options...
AndyB Posted July 7, 2008 Share Posted July 7, 2008 These look suspect as well $headers == array( $string = preg_replace($headers, '',string); Link to comment https://forums.phpfreaks.com/topic/113403-t_string-errorposting-my-codeplease-explain-why-this-isnt-working/#findComment-583170 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.