+ 3

so how do i link a php file to an html file if im using xampp ?

ive tryed making a php file in the htdocs like this: <html> <body> <form action="first.php" method="post"> <p>Name:<input type="text" name="name"></p> <p>Age<input type="text" name="age"></p> <p><input type="submit" name="submit" value="submit"></p> </form> <?php echo "hi". $_Post ["name"].".";?> <br/> <?php echo $_Post ["age"];?> </body> </html> but it keeps saying, Notice: Undefined variable: _Post in C:\xampp\htdocs\first.php on line 8 hi. Notice: Undefined variable: _Post in C:\xampp\htdocs\first.php on line 10 . ive even tried just using an an html file and php separate but still no results.

19th Jun 2017, 3:16 AM
Hoeft Brian
Hoeft Brian - avatar
10 Answers
+ 6
Try this.. save both files in the same folder 1)This is index.php or can be saved as index.html also <html> <body> <form action="welcome.php" method="post"> Name: <input type="text" name="name"><br> E-mail: <input type="text" name="email"><br> <input type="submit"> </form> </body> </html> 2)This is "welcome.php" only. <html> <body> Welcome <?php echo $_POST["name"]; ?><br> Your email address is: <?php echo $_POST["email"]; ?> </body> </html> I hope this can help😊
19th Jun 2017, 2:21 AM
Marco Macdon
Marco Macdon - avatar
+ 6
did you put some input on the textfield? or did you enter any data? that code should work.
19th Jun 2017, 3:44 AM
Marco Macdon
Marco Macdon - avatar
+ 4
did you copy and paste the codes or you manually typed it?
19th Jun 2017, 10:50 AM
Marco Macdon
Marco Macdon - avatar
+ 2
@Marco Macdon i tried it like you showed but now it just shows Welcome: Your email address is: how would i get the name and email to actually show ? you have been very helpful.
19th Jun 2017, 3:32 AM
Hoeft Brian
Hoeft Brian - avatar
+ 2
so i figured out to just do it all in the same php file i can run it like this. in a php file named "test.php" <html> <body> <form action="" method="POST"> <p>Name:<input type="text" name="name"></p> <p>E-mail: <input type="text" name="email"></p> <input type="submit" name="submit" value="submit"> </form> <?php echo "Hi , ". $_POST['name']; ?> <br/> <?php echo "Your Email is , ". $_POST['email']; ?> </body> </html> i left the action empty so it opens in its self and it worked smoothly.
20th Jun 2017, 2:11 AM
Hoeft Brian
Hoeft Brian - avatar
+ 1
in the other file which is first.php <html> <body> <?php $name = $_POST['name']; ?> </body> </html> and so on this is how to link between them
19th Jun 2017, 1:12 AM
Mohamed Nashaat
Mohamed Nashaat - avatar
+ 1
thanks ill try that.
19th Jun 2017, 2:38 AM
Hoeft Brian
Hoeft Brian - avatar
+ 1
i enterd random for the name and used email for email but they returnd blank
19th Jun 2017, 9:49 AM
Hoeft Brian
Hoeft Brian - avatar
+ 1
copy and paste just to test
19th Jun 2017, 10:51 AM
Hoeft Brian
Hoeft Brian - avatar
+ 1
if i use a $_get name with an if statement to return the name with a $_post would that work ?
19th Jun 2017, 4:46 PM
Hoeft Brian
Hoeft Brian - avatar