+ 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.
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đ
+ 6
did you put some input on the textfield? or did you enter any data? that code should work.
+ 4
did you copy and paste the codes or you manually typed it?
+ 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.
+ 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.
+ 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
+ 1
thanks ill try that.
+ 1
i enterd random for the name and used email for email but they returnd blank
+ 1
copy and paste just to test
+ 1
if i use a $_get name with an if statement to return the name with a $_post would that work ?