This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 8 years ago.
I was following a guide on creating a secure log in with PHP, it was relatively easy to understand since I am very new to the language. When I finished I tried to check it out on my MAMP server, and none of the form for the register page shows up. What could be causing this?
tutorial I used here: http://www.wikihow.com/Create-a-Secure-Login-Script-in-PHP-and-MySQL
The Code in Question: (HTML / PHP)
<form action="<?php echo esc_url($_SERVER['PHP_SELF']); ?>"
method="post"
name="registration_form">
Username: <input type='text'
name='username'
id='username' /><br>
Email: <input type="text" name="email" id="email" /><br>
Password: <input type="password"
name="password"
id="password"/><br>
Confirm password: <input type="password"
name="confirmpwd"
id="confirmpwd" /><br>
<input type="button"
value="Register"
onclick="return regformhash(this.form,
this.form.username,
this.form.email,
this.form.password,
this.form.confirmpwd);" />
</form>
I have tried using a different style of formatting, but I believe it's directly related to the echo esc_url in the form action, any ideas on fixing this?
My form does display with this syntax:
<form>
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>
At first try clearing your cache in the browser , check if every file is correct in your MAMP.
<form action="" method="post" >
replace:
<input type="button"
value="Register"
onclick="return regformhash(this.form,
this.form.username,
this.form.email,
this.form.password,
this.form.confirmpwd);" />
to:
<input type="submit" value="register"name="register">
PHP:
if(isset($_POST['register']))
{
//whatever you want your form to do
}
Related
This question already has answers here:
Trigger standard HTML validation (form) without using submit button? [duplicate]
(13 answers)
Closed 7 months ago.
I'm new to coding in HTML. After hours of searching the internet for a way to do this, I failed and so I'm here. I want to redirect user to another page ONLY AFER USER FILLED ALL INPUTS IN THE FORM
but here if user will click submit it will redirect to next page.
<form action="home.php" method="post">
<div>
<input type=text name="username">
<label>Email or phone number</label>
</div>
<div>
<input type=text name="username">
<label>Phone</label>
</div>
<button type=submit name="submit">Sign In</button>
Use the required attribute. Example below:
<form action="home.php" method="post">
<div>
<input type=text name="username" required>
<label>Email or phone number</label>
</div>
<div>
<input type=text name="username" required>
<label>Phone</label>
</div>
<button type=submit name="submit">Sign In</button>
You can combine this attribute with other attributes, like pattern, to define a requirement in a more specific input.
At the same time, it is still necessary to check user input on the server.
You should use radio box. For example your html code:
<input type="radio" name="contact" id="contact_email" value="email" />
<label for="contact_email">Email</label>
and now, you can check if it's "checked" with php code below:
if(isset($_POST['contact'])) {
// code to redirect, for example header...
}
This question already has answers here:
Can you nest html forms?
(21 answers)
Closed 4 years ago.
My code looks somewhat like this:
<form method="POST">
//something
<form method='GET'>
<input readonly type='text' id='userpwd' value= 'Day' name='count'/>
<input type='submit' id='btn' formaction='admi.php' name='admin' value='Add Details'></form>
<input type="submit" id="btn" formaction="choose.php" name="admin" value="Done"></p>
</form>
I want to get the value of readonly type input in my new php file.How could I achieve this.I tried doing this:
$var=$_GET['count'];
but it is giving following error msg:
Notice: Undefined index: count in C:\xampp\htdocs\tourism\admi.php on line 4
Please somebody help me out..!Kindly give some solution in php only.
<form> element shouldn't be nested:
4.10.3. The form element
Content model:
Flow content, but with no form element descendants.
HTML 5.2 Recommendation
Can't you do both forms seperate (not nested)?
Edit: If you need a readonly field to be sent in your form, you can add a hidden field with the same value :
<input type="hidden" name="count" value="Day" />
<input type="text" name="count" value="Day" readonly />
<?php
if(isset($_GET['txtUserPwd'])) { echo "<div>" . $_GET['txtUserPwd'] . "</div>"; }
else { ?>
<form method="GET">
<input type="text" id="txtUserPwd" name="txtUserPwd" value="Day" readonly />
<input type="submit" id="btnAdmi" name="btnAdmi" value="Add Details">
<input type="button" id="btnChoose" name="btnChoose" value="Done">
</form>
<?php } ?>
This doesn't address your second button. I would do that with JavaScript or jQuery.
I'm trying to create a form post within a larger block of PHP code, but overall my web page fails to load. To troubleshoot this, I've commented out a specific section of code and I think I've found where my error code be, even if I don't know what that error is -- when this code is commented, my page works, albeit without the added content below.
echo '<form method="POST" action="addPeople.php">
First Name: <input type="text" name="FirstName"><br>
Last Name: <input type="text" name="LastName"><br>
Birthdate: <input type="text" name="Birthdate"><br>
Birth City: <input type="text" name="BirthCity"><br>
Birth State: <input type="text" name="BirthState"><br>
Region: <input type="text" name="Region"><br>
<input type="submit" name = "submit" class="button tiny round" value="Add Person" />
</form>'
Have I overlooked a syntax error with my quotations? Or maybe I'm just not handling the form method correctly? Would really appreciate some insight.
You forgot the ;.
Try :
echo '<form method="POST" action="addPeople.php">
First Name: <input type="text" name="FirstName"><br>
Last Name: <input type="text" name="LastName"><br>
Birthdate: <input type="text" name="Birthdate"><br>
Birth City: <input type="text" name="BirthCity"><br>
Birth State: <input type="text" name="BirthState"><br>
Region: <input type="text" name="Region"><br>
<input type="submit" name = "submit" class="button tiny round" value="Add Person" />
</form>';
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
first file is index.php
<?php include('loginform.php');?>
second file is loginform.php
<?php
<html>
<body>
<form action="" method="post">
<label>Username</label>
<input type="text" name="username"><br>
<label>Password></label>
<input type="password" name="password"><br>
<input type="submit" name="submit" value="login">
</form>
Register here
</body>
</html>
?>
third file is register.php
<html>
<body>
<form action="" method="post">
<label>FirstName</label>
<input type="text" name="firstname"><br>
<label>LastName</label>
<input type="text" name="lastname"><br>
<label>Email</label>
<input type="email" name="email"><br>
<label>UserName</label>
<input type="text" name="username"><br>
<label>Password</label>
<input type="password" name="password"><br>
<input type="submit" name="submit" value="Register">
</form>
</body>
</html>
I have three files in the project first file is the index file which is shown whenever the user opens the website It contains two things login form and a link
ie register here.So i have wrapped all this in one single php file loginform.php
and included it in my index.php file so when I execute this in my localhost web server it shows a error like this
Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\cms\loginform.php on line 2
How can I tackle this problem please tell me?
The loginform.php file isn't a PHP source file, it's just an HTML file. Remove the enclosing <?php and ?> from it and you should be OK.
This question already has answers here:
Make a link use POST instead of GET
(11 answers)
Closed 7 years ago.
Is there a way to replicate this in <a href="blah.php">?
<form action="http://localhost/php/suburb_added.php" method="post">
<b>Add a New Suburb</b>
<p>Name:
<input type="text" name="suburb" size="30" value="" />
<input type="submit" id="submit" value="Submit" name="submit" />
</p>
</form>
in suburb_added.php... i have this to capture
if (!empty($_POST['suburb']))
To a table form....
<td align="left"><a href="suburb_added.php"><?php echo $row['id'];?></td>
how to create the items below from a table? The goal is when I click the result from <?php echo $row['id'];?>, I should be able to get the value of "id" and process it in suburb_added.php using similar to if (!empty($_POST['suburb']))
<form action="http://localhost/php/suburb_added.php" method="post">
<input type="text" name="suburb" size="30" value="" />
what do you whant i don't understand?? I can help you
<?php
if(!isset($_POST['submit'])){
?>
<form action="" method="post" name="submit">
<b>Add a New Suburb</b>
<p>Name:
<input type="text" name="suburb" size="30" value="" />
<input type="submit" id="submit" value="Submit" name="submit" />
</p>
</form>
<?php
} else {
//paste here your code from http://localhost/php/suburb_added.php
echo "you doing post in this page.";
}
?>
<!--Try using header
like this:-->
if($_POST)
{
header('location:login-form.php');
}
else
{
echo "";
}
Change the PHP script so it uses $_REQUEST instead of $_POST. This variable combines the contents of $_POST and $_GET. Then you can have a link like
<?php echo $row['id'] ?>