Jump to content

Simple PHP script wont run without errors

- - - - -

  • Please log in to reply
1 reply to this topic

#1
hamster50

hamster50

    Newbie

  • Members
  • Pip
  • 1 posts
Basically, display.html is the form where the user enters his First and Last name then clicks submit. When the person does that it is supposed to take them to /display.php?first_name=First?last_name=Last where it says Welcome: First Name/Last Name. I didn't include the main.css file because it is not a visual error but a programming error.

The error I get: "Notice: Undefined variable: first_name in \display.php on line 13" (Picture below)
Posted Image

display.php
<?php

	// get the data from the request

	$fist_name = $_GET['first_name'];

	$last_name = $_GET['last_name'];

?>

<html>

	<head>

		<title>Name Test</title>                                                                        

		<link rel="stylesheet" type="text/css" href="main.css"/>

	</head>

	<body>

		<h2>Welcome</h2>

		[B]<p>First Name: <?php echo $first_name; ?></p>[/B]

		<p>Last Name: <?php echo $last_name; ?></p>

	</body>

</html>

display.html
<html>

	<form action="display.php" method="get">

		<label>First Name:</label>

		<input type="text" name="first_name"><br>

		<label>Last Name:</label>

		<input type="text" name="last_name"><br>

		<label> </label>

		<input type="submit" value="Submit">

	</form>

</html>

Any help would be appreciated. I have tried the last couple hours to figure it out but not sure. I want to move ahead in my textbook but don't want to overlook errors.

#2
bleastan

bleastan

    Learning Programmer

  • Members
  • PipPipPip
  • 40 posts
// get the data from the request
$fist_name = $_GET['first_name'];
$last_name = $_GET['last_name'];

Try changing $fist_name to $first_name :)
You forgot the R in first_name :)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users