so I'm currently following this tutorial on PHP forms and ive made it to the bottom of this page where it says to test the form so far, http://www.webreference.com/programming/php/search/2.html
"Save your file and test your form at this point (search_display.php)."
When I go to type in a users name in thew design view of dreamweaver and hit submit nothing happens (as if the page is refreshing) however, when i navigate to my file from my MySQL (XAMP and phpMyADmin) server directory i can view my search page but there is no text box/area for me to enter in any data. I have followed/copied this tutorial verbatim and im quite unsure on why I can not get my data to submit to the query. Here is the code for my search page
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Search Contacts</title>
</head>
<p>
<body>
<h3>Search Contacts Details</h3>
<p>You may search either by first or last name</p>
<form method="post" action="search.php?go" id="searchform">
<p>
<input type="submit" name="submit" value="Search">
</p>
</form>
</body>
</p>
</html>
Thanks guys for the help.
Your HTML form is missing a text field. Please check the HTML sample on the first tutorial page.
Side note: you really should not be following this tutorial as it is greatly outdated, teaches bad practices and will not work when using PHP 7+ due to the removed mysql extension.
1. Place this code where you need the form. For example index.php . There is no input field in your form. So add input fields. For example i am adding email and mobile no as input fields
<h3>Search Contacts Details</h3>
<p>You may search either by first or last name</p>
<form method="post" action="search.php" id="searchform">
<input type="text" name="email" value="">
<input type="text" name="mobileno" value="">
<input type="submit" name="submit" value="Search">
</form>
2. Create another page called search.php and place the below code here
if(isset($_POST['submit'])){
$email = $_POST['email'];
$mobileno = $_POST['mobileno'];
}
Validate all the fields before inserting into database.
Related
I have a HTML form where after the user submits the form they see my FormSubmit.php thank you page. Is there a way to make that thank you page still display after submission, but also add a link to another php page that shows you a list of who added their names?
I created a SignupList.php page that reads from a text file. I added the link to the form HTML page at the bottom and to the FormSubmit.php thank you page, but when I add a name ,reach my FormSubmit.php thank you page, then click the link to my SignupList.php page there are no names on it. I noticed on the HTML page in the form action section when I replace FormSubmit.php with SignupList.php I get my desired results a name displays after hitting submit, but my thank you page is gone since I removed the action to it. Any suggestions on how I can do both? Please let me know if I need to explain further.
<!DOCType html>
<html>
<head>
<title>Form</title>
<html lang="en">
<link rel="stylesheet" type="text/css" href="css/stylesheet.css">
</head>
<body>
<form method="post" action="FormSubmit.php">
<p>Please sign up</p>
<p> First Name:<br>
<input type="text" name="firstname" size="30">
</p>
<p> Last Name:<br>
<input type="text" name= "last name" size="30">
</p>
<p>
<input type="submit" value="Submit Information">
</p>
View Sign Ups
</form>
</body>
</html>
edit: I am not sure why i was down voted, but i figured out the issue. I needed to edit my FormSubmit.php file to write to the document.
In your Formsubmit.php, add:
header('Refresh: 3;url=page.php');
which will refresh the header and redirect the page after 3 seconds.
I have a database with some numbers assigned to a fake account (PHP).
I try to contact the database (with success) and get the right result from the form.
My issue is that the form result open a new page and display there...
I would really like the result to be displayed IN the module I use to send the form OR anywhere else on the same page I used to send the form.
<!DOCTYPE html>
<html>
<body>
<form
method="post"
action="http://ggdbase.dx.am/impulseGetInfo.php"
target="_self">
Account name:<br>
<input type="text" name="name" value="derps">
<br>
<input type="submit" value="Click To Load Account Info">
</form>
</body>
</html>
This is what the module look like (on Enjin.com)
This is what I get when clicking the button
I did try replacing '_self' with '_blank' or parent and all the other options I could find but none of them gave me a different result :S
Could it be caused by the Enjin system itself ?
Do not use target. And replace the action as
action=""
This will ensure that you are calling the same page. Write the PHP code there itself.
Hope that help!
I have just started to learn HTML and PHP, but have run into a road block while following beginner tutorials. I am attempting to have the user input numbers into a form on the HTML page, then press submit to redirect to a PHP page that displays the values. The PHP page shows up and successfully displays prepared text but displays nothing for the values.
HTML code:
<html>
<body>
<head>
<title>Practice Page</title>
</head>
<h1>Numbers</h1>
<p>Put numbers in the boxes</p>
<form action="welcome.php" method="post">
NumOne: <input type="text" name="oynumone"><br>
NumTwo: <input type="text" name="oynumtwo"><br>
<input type="submit" value="Submit" id="SubmitRegister" name="submit" />
</form>
</body>
<html>
PHP code:
<html>
<body>
Number one is <?php echo $_POST["oynumone"]; ?><br>
Number two is <?php echo $_POST["oynumtwo"]; ?>
</body>
</html>
Both of the files are simply in the same folder in my documents. I understand that I need a server to host PHP content; I have downloaded MAMP for this, but I don't yet understand how to use it.
Any help would be most appreciated.
Store both file name with .php extension AND/OR update Welcome.php like below -
Welcome.php
<?php
if isset($_POST['submit'])
{
$oynumone = $_POST['oynumone'];
$oynumtwo = $_POST['oynumtwo'];
echo "Number one is ".$oynumone;
echo "Number two is ".$oynumtwo;
}
?>
Also check this
I am just starting out in PHP/Html web development.
I have a basic page with a username and password field and a submit button.
I want to get the data from the username and password boxes into the php.
Here is my code...
<html>
<head>
<title>PAGE TITLE</title>
</head>
<body>
<h1 align = "center">Harro</h2>
<form align = "center">
Username: <input type="text" name="firstname"> <br>
Password: <input type="password" name="pwd"> <br>
<input type="submit" value="Enter">
<?php
???
?>
</form>
</body>
Specify the URI of the PHP program the form should be submitted to using the action attribute.
<form action="foo.php">
Then, when the form is submitted, PHP will populate the $_GET or $_POST superglobal with the data.
What you want is learning to code PHP web-apps from ground-up.
Currently what you will get from answers is just the code to get the Username and Password from the user. But the main thing comes after that. Like validation, and checking the login information from the database and then retrieving it.
Personally, I would recommend you to read O'Reilly Media's Learning PHP, MySQL, JavaScript, and CSS.
add name attribute in submit button
eg: name="submit"
And
add attribute in form tag method="post"
and write php code at top
<?php
if(isset($_POST['submit'])){
echo "USERNAME ".$_POST['firstname'];
echo "PASSWORD ". $_POST['pwd'];
}
?>
I have written some basic code so that a text area is displayed, and when the user inputs the text, clicks submit and it shows on the page in the method=''.
The code i have for the form is :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Fun Translator</h1>
<form method="post" action="query.php">
<textarea name="txtarea">
</textarea>
<input type="submit" />
</form>
The code on the page query.php is:
<html>
<body>
<?php
echo $_POST["txtarea"];
?>
</body>
</html>
By looking at google, other questions and such, this should work, but doesnt!
Solution:
Thanks to Marc Audet, I put in phpinfo and all that came up in a big table as it does, I took it out and it started working. Any explanations?
this code is perfectly fine. something else is going wrong.
The textarea is not link to your form, you should add form="" in textarea like this:
<form method="post" action="query.php" name="myform">
<textarea name="txtarea" form="myform">
use
echo htmlspecialchars($_POST['name']);
to get value.
some browsers like the ID...
add an ID like this:
<form method="post" action="query.php">
<textarea name="txtarea" id="txtarea">
</textarea>
<input type="submit" />
</form>
Best guess: Your server doesn't support PHP.
Check the source code as delivered to the browser. If the <?php bit shows up, then the server hasn't run the page through a PHP engine.
As far as I know you should be doing textarea in the quotes not txtarea, I am not really sure though, it might be beneficial to use an ID instead.