Html/php Form Gives Me 500 Internal Server Error When Adding More Input Fields
Hi, I have a problem with my php and html form. What I am trying to do is just get a form with 7 input fields, 6 of these are input field or text area and one will be a checkbox. I
Solution 1:
The problem is that in the 2nd example you're trying to pass 6 variables to the mail() function when it accepts 5. Check here on how you can pass additional headers.
Solution 2:
6 Variables will result in:
Warning: mail() expects at most 5 parameters, 6 given in YOUR WEBSITE on LINE
Solution example:
<?php
//var_dump($_POST);
if (isset($_POST["subject"]))
{
$subject = $_POST["subject"];
$message = $_POST["message"];
$first = $_POST["first_name"];
$last = $_POST["last_name"];
$name= "$first $last";
}
$message = wordwrap($message, 70);
$first = wordwrap($first, 70);
$last = wordwrap($last, 70);
mail("summat@gmail.com",$subject,$message,$name,"subject: $subject\n");
echo "Thank you for sending us feedback";
?>
Answer to your reply:
Php:
<?php
//var_dump($_POST);
if (isset($_POST["subject"]))
{
$subject = $_POST["subject"];
$message = $_POST["message"];
$first = $_POST["first_name"];
$last = $_POST["last_name"];
$company = $_POST["company"];
$email = $_POST["email"];
$telnr = $_POST["telnr"];
$description = $_POST["description"];
$therest = "First name= $first" . "\r\n" . "Last name= $last" . "\r\n" . "Last name= $last" . "\r\n" . "Company= $company" . "\r\n" . "Email= $email" . "\r\n" . "Telnr= $telnr" . "\r\n" . "Description= $description";
//echo "$therest <br>";
$message = wordwrap($message, 70);
$first = wordwrap($first, 70);
$last = wordwrap($last, 70);
mail("Your Email Address Here",$subject,$name,$therest,"subject: $subject\n");
echo "Thank you for sending us feedback";
}
HTML
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
<input type="hidden" name="subject" value="can you create me an account"><br>
Message: <textarea rows="10" cols="40" name="message"></textarea><br>
first <input type="text" name="first_name" ><br>
last <input type="text" name="last_name" ><br>
company <input type="text" name="company" ><br>
email <input type="text" name="email" ><br>
Telephone number <input type="text" name="telnr" ><br>
Description <input type="text" name="description" ><br>
<input type="submit" name="submit" value="Submit Feedback">
</form>
Demo: here
It will send the mail to the mail your entered in the form
Post a Comment for "Html/php Form Gives Me 500 Internal Server Error When Adding More Input Fields"