John Davidson

A problem with processing data from html form with PHP

0 comments
Message:


I'm just about to learn php and that is my first try to process data from an html form. I was writing this php code using some articles from the Internet and it seems to be correct but after entering all the data and than pressing "submit" nothing is happening. I mean just a white browser screen.


Here is my code:




<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>form</title>
</head>

<body>
<form method="post" action="form__2.php">
<label for="surname">Surname</label>
<input type="text" name="surname" placeholder="Johnson" required> <br>
<label for="name">Name</label>
<input type="text" name="name" placeholder="Carl" required> <br>



<label>Gender:</label>
<label for="male">M</label>
<input type="radio" name="male" checked>
<label for="female">F</label>
<input type="radio" name="female"> <br>

<label for="education">Education:</label>
<select id="education" name="education" required>
<option value="less-basic">Less than basic</option>
<option value="basic">Basic</option>
<option value="mid-school">Middle-school</option>
<option value="high-school">High-school</option>
<option value="bachelor">Bachelor's or equivalent</option>
<option value="master">Master's or equivalent</option>
<option value="doctor">Doctorate or equivalent</option>
</select> <br>

<label for="courses">Enroll in courses</label>
<input type="checkbox" name="courses" required> <br>

<label>Was you dealing with our company later?:</label>
<label>Yes</label>
<input type="radio" name="company" value="yes" checked>
<label>No</label>
<input type="radio" name="company" value="no"> <br>

<input type="submit" name="submit">
</form>
</body>

</html>


My Answer:
submit, nothing happens. Can someone please help me figure out what the problem might be?

Here is my php code:

php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

echo "Name: " . $name . "
";
echo "Email: " . $email . "
";
echo "Message: " . $message . "
";
}
?>


And here is my html form:

html
">
Name:

Email:

Message:





I have checked the code multiple times and it seems to be correct. I'm not sure why the data is not being processed when I submit the form. Any help would be greatly appreciated. Thank you.

Rate this post

4 of 5 based on 9394 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us