문제

1.php

include'form.html'

form.html

<form action="email.php" method="post">
<input type="text" id="name" value="name" />
</form>

email.php

<?php
$name = $_POST['name']; 
$email_message = "Name: $name ";
$sent = mail($email_to, $email_subject, $email_message); 
if($sent) {
    echo "success=yes";
} else {
    echo "success=no";
}
include('success.html');
?>

error:

Notice: Undefined index: name in C:\wamp\www\a\action.php on line 3

I also tried making them global variables in form.html but not working

도움이 되었습니까?

해결책

insert name="name" input tag of the form. like this

<input type="text" id="name" value="name" name="name" />

The name attribute specifies the name of an element. The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted. Only form elements with a name attribute will have their values passed when submitting a form.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top