Jump to content

MySQL php data entry Won't Work...


abrogard

Recommended Posts

Can anyone point out what's wrong with my feedback.php?  It used to work fine and I don't think I did anything but it stopped working - i.e. I had it on a site which I never looked at and when I did look at it I noticed the rubbish written to the database had inexplicably stopped being written there some months ago.....

 

since then I've tried to clean it up and use it elsewhere ( I'm a baby at php and most else) but I can't get it to go right.

 

In this attempt it was giving me the dreaded 'headers already written..' error and I (after googling) took out all the blank space I could and extra comments and what not and stuck in some debugging prints for me and now I get no errors but I get nothing written to the database and no email sent to me.

 

If anyone cares to look at it to help me out, here it is, warts and all, with just the names changed to protect the innocent.

 

<?

//  mail it

$mailto = 'med@yahoo.com' ;

$subject = "Ploverpark Feedback Form" ;

$formurl = "feedback.html" ;

$errorurl = "error.html" ;

$thankyouurl = "thankyou.html" ;

$uself = 0;

$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;

$username = $_POST['username'] ;

$firstname = $_POST['firstname'] ;

$email = $_POST['email'] ;

$comments = $_POST['comments'] ;

$secondname = $_POST['secondname'] ;

$country = $_POST['country'] ;

$phone = $_POST['phone'] ;

 

// do write to database now---------------------------

$link = mysql_connect("mydb.com", "my_pkguest", "password") or die("Could not connect  : " . mysql_error());

  print "Connected successfully<p>";

  $DB = "my_pkguest";

  $table = "clients";

  mysql_select_db($DB) or die ("Database $DB not select.." . mysql_error());

  print "Successfully select the Database: $DB ";

$query = "INSERT INTO $table(username,firstname,secondname,email,country,phone,comments)  values('$username','$firstname','$secondname','$email','$country','$phone','$comments')";

  print "Successfully inserted to table: $table ";

 

//------------------------------------------------------

 

$http_referrer = getenv( "HTTP_REFERER" );

 

if (!isset($_POST['email'])) {

header( "Location: $formurl" );

exit ;

}

print "Now past the if isset ";

 

//if (empty($name) || empty($email) || empty($comments)) {

//  header( "Location: $errorurl" );

//  exit ;

//}

if ( ereg( "[\r\n]", $username ) || ereg( "[\r\n]", $email ) ) {

header( "Location: $errorurl" );

exit ;

}

print "Now past the if ereg ";

if (get_magic_quotes_gpc()) {

$comments = stripslashes( $comments );

}

$messageproper =

"This message was sent from:\n" .

"$http_referrer\n" .

"------------------------------------------------------------\n" .

"UserName of sender: $username\n" .

    "Firstname of sender: $firstname\n" .

"Secondname of sender : $secondname\n" .

"Country of sender : $country\n" .

"Phone number of sender: $phone\n" .

"Email of sender: $email\n" .

"------------------------- COMMENTS -------------------------\n\n" .

$comments .

"\n\n------------------------------------------------------------\n" ;

print "Now past the messageproper ";

mail($mailto, $subject, $messageproper,

"From: \"$username\" <$email>" . $headersep . "Reply-To: \"$username\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.07" );

print "Now past the mail";

//header( "Location: $thankyouurl" );

//  exit ;

?>

Link to comment
Share on other sites

 

I couldn't edit that post - that's why it is still there.

 

So STUPID! 

 

Nothing is written to the database because there's no command to write anything.

 

Sorry, sorry, sorry.  I don't think they do it in these forums but it'd please me if the moderator deleted the whole thing. My face is red.

 

:(

 

Link to comment
Share on other sites

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.