I've just got into php recently, and now i am working on a login form which has a signup page and a signup script to do all the database and such. But my $_POST is not working at all. I`ve tried searching online, confirm that my xampp/php/php.ini setting enable post process, and such. But all i get is nothing. To make the problem simpler i used a post tutorial code online
Posttest.php
<!DOCTYPE HTML>
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" id="name" name="name"><br>
E-mail: <input type="text" id="email" name="email"><br>
Submit
</form>
</body>
</html>
welcome.php
<html>
<body>
<?php
$disname="";
$disname = isset($_POST['name']) ? $_POST['name'] : '';
echo "$disname is your username";
var_dump($_POST);
?>
</body>
</html>
and the result is empty. Please help i`ve been working on this problem for few days.
Everything looks fine but the submit href link, which you should replace with a Submit input type:
Submit
to:
<input type="submit">
You can't use "a" tag for submit. "a" tag just direct to address. So you should use this:
<input type = "submit" value = "Submit">
<!DOCTYPE HTML>
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" id="name" name="name"><br>
E-mail: <input type="text" id="email" name="email"><br>
<input type = "submit" value = "Submit">
</form>
</body>
</html>
///////////////////////////////////////////////////////
//////welcome.php
<html>
<body>
<?php
$disname="";
$disname = isset($_POST['name']) ? $_POST['name'] : '';
echo "$disname is your username";
var_dump($_POST);
?>
</body>
</html>
Related
Consider following html page:
index.html
<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>
If GET is used for reading the data let's say "name" then following is understandable:
welcome.php
<html>
<body>
Welcome <?php echo $_GET["name"]; ?><br>
Your email address is: <?php echo $_GET["email"]; ?>
</body>
</html>
When POST is meant for writing the data How is it possible to read the "name" using POST? Why should the following work?
<html>
<body>
Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html>
First of all add a name in your submit input <input name="submit" type="submit">
Second into welcome.php add if(isset($_GET["submit"])){ $submit = preg_replace('#[^a-z0-9]#i', '', $_GET['submit']); }
and then use Welcome <?php echo $submit; ?>
i suggest to use preg_replace if you want to pass values from page to page
I am using Post form, which works perfectly with any text, but when try to post code like format=xhtml, redirect me to 404
I am on this already all night and can not solve it with google`s help.
It is PHP page
Works on the example page
https://tryphp.w3schools.com/showphp.php?filename=demo_form_post
Does not work on my server
I am posting
content="format=xhtml; url=https://m.1688.com/offer/42866153932.html" />
Here is the example code
<!DOCTYPE HTML>
<html>
<body>
<form action="test45.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html>
<?php
//include "fetchpage.php";
?>
<?php
echo "Welcome ";
echo $_POST['name'];
echo "<br> Your e-mail address is:$nbsp";
echo $_POST['email'];
?>
You need to understand php form handling first.
Please go through this link php form handling
OR
Just see the code below..
<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>
AND PHP CODE SHOULD LOOK LIKE THIS...
<?php
echo "Welcome ";
echo $_POST['name'];
echo "<br> Your e-mail address is: ";
echo $_POST['email'];
?>
Get it run on: CLICK HERE...
HOPE IT HELPS...
I've just started using PHP forms for my website prototype, and it wasn't working so I decided to try to make a basic form example. No fancy CSS, just pure data. This is the code.
Index.html
<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>
welcome.php
<html>
<body>
Welcome <?php echo $_POST["name"]; ?>
<br />
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html>
The code works as far as displaying the 'Welcome ___ Your email address is: ____.
It just doesn't display the data entered in the form. For clarification as to whether my PHP works, I have tried just displaying some text and it worked fine. I use the PHP Editor phpDesigner8.
Thanks!
This code is from w3schools which displays the email address and name once the user submits the form. However when I tried copying the code it wouldn't let me display the same output and would only say Cannot POST /welcome.php or it would display the welcome.php code whenever i submit.
I didn't even alter it in anyway but why wont it work? D:
index.html
<!DOCTYPE HTML>
<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>
welcome.php
<html>
<body>
Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html>
Here i entered name nd email id but when i click on submit button my entered information is blank like below image.
In PHP clicking on the submit button doesn't print the information. I used $GET and $POST, both are not working.
<!DOCTYPE HTML>
<html>
<body>
<form action="php_forms.php" method="post">
Name: <input type="text" name="name"><br>
Email: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html>
<html>
<body>
Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html>
It should be work.Change your action (php_forms.php) file code.I have tried in my server.Hope it will be helped.
<html>
<body>
Welcome <?php echo htmlspecialchars($_POST["name"]); ?><br>
Your email address is: <?php echo htmlspecialchars($_POST["email"]); ?>
</body>
</html>
Read More dealing with html forms in PHP.NET.
Your form uses get method and php_forms.php uses post method. Try
<form action="php_forms.php" method="post">