質問

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