Jump to content

Recommended Posts

Please please help - getting so frustrated.

 

My script is meant to Email someone (that works), and also is meant to insert data into a db.

 

It won't do the database thing.

 

Please look at my code and help me - thanks so much!

 

<?php
$name = $_POST['name'];
$business_name = $_POST['business_name'];
$emailm = $_POST['email'];
$contact = $_POST['contact'];
$id = $_POST['id'];


include('connectdb.php');

  $cemail = "no-reply@email.com";
  $headers  = "From: $cemail\r\n";
    $headers .= "Content-type: text/html\r\n"; 

include('email.php');

$to = $email;
## Below is for new email
$message = "Hello, <br /><br />You have been sent an email regarding " . $business_name . ". <br /><br />Please note, this message has not been screened by FoodFinder staff and FoodFinder is not responsible for it's content.<br /><br />Regards,<br />FoodFinder Staff<br /><br />Submitted Content:<br /><br />Name: " . $name . "<br />Contact: " . $contact . "<br />Message: " . $emailm . "";
$subject = "FoodFinder Contact";


mail($to,$subject,$message,$headers);
echo $id . "<br>" . $name . "<br>" . $contact . "<br>" . $emailm . "<br>" . $message;


//////////////////


$sql="INSERT INTO submitted_emails (buzzid, name, contact, message, email)
VALUES
('$id','$name','$contact','$emailm','$message')";



?>

 

Thanks,

Sam.

Link to comment
https://forums.phpfreaks.com/topic/88092-please-help-insert-error/
Share on other sites

Did you actually do what I suggested in the other post?  Because you were getting errors because of apostrophes then, and I don't see any changes in your code:

 

Either addslashes() or mysql_real_escape_string() the strings you're inputting.  The reason it'll be generating errors is because you have an apostrophe in one of your inputs somewhere.

 

Do this at your string input stage:

 

 

<?php

$name = mysql_real_escape_string($_POST['name']);

// OR

$name = addslashes($_POST['name']);

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.