Jump to content

[SOLVED] PHP error_get_last problem


bschmitt78

Recommended Posts

I just recently got an error while trying to solve an ongoing PHP problem for  website I have built.

 

The error log reads: "Fatal error: call to uundefined function, line 42 error_get_last." As I said, this error JUST popped up - how do I fix this?

 

Also, I have not been able to get PHP variable content sent to my email address by form users. All I get is a blank email. I know the problem lies with my $header variable, but I am not sure how to fix it. Here is my script:

 

<html>

<head>

       

<title>maillist.php</title>

</head>

<body>

 

<?php

 

$to = "[email protected]";

$subject = "Contact Us";

 

$headers = "From: [email protected]"; (***since this is coming from my website, should I replace the from address with some other address?? ****)

$name = $_POST['name'];

$address = $_POST['address'];

$city = $_POST['city'];

$state = $_POST['state'];

$zip = $_POST['zip'];

$phone = $_POST['phone'];

$email = $_POST['email'];

$comments = $_POST['comments'];

$message = "$name\n$address\n$city\n$state\n$zip\n$phone\n$email\n$comments";

$sent = mail($to, $subject, $message, $headers);

 

//print thank-you message

if ($sent == true)

 

{

 

//redirect to home page

echo "Thank you, <b>$name</b>. We will contact you soon.";

header ('Refresh: 3; URL = http://www.mysite.org');

exit();

 

}

 

else

 

{

 

echo "Something went wrong with mail!";

print_r(error_get_last());

header ("Location: http://www.mysite.org/maillist.html");

exit();

 

}

 

?>

</body>

</html>     

 

I am new to prgramming with PHP so any help would be appreciated! I am anxious to get these prblems solved.

Link to comment
https://forums.phpfreaks.com/topic/50202-solved-php-error_get_last-problem/
Share on other sites

Honestly, I don't know. I just tried to find out what PHP version Yahoo! (my host) supports and couldn't find the answer. Maybe someone in this forum or you might know?

 

Also, any ideas as to what might be causing my form handling problem (the blank emails?)

 

 

Gotcha. I took the error_get_last function out completely. Also, I changed if ($sent==true) to if (isset($_POST['submit'])) and this fixed my existing problem with echoing the $name variable to the php page, but now I am not receiving an email at all. I was getting emails before but they were blank. Do you see a problem with my PHP code?

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.