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 = '[email protected]' ;

$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
https://forums.phpfreaks.com/topic/218549-mysql-php-data-entry-wont-work/
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.

 

:(

 

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.