I am new to html & php and I appreciate your help. I am trying to accept user input into a webpage and then after the user clicks the submit button, write a new record out to MySQL. I am using Wordpress so the tags are not exactly textbook.
So my first problem is that the submit button does not appear to execute the php code. I also would appreciate it if someone could check how I am passing my html field names to the php variables to make sure that I am on the right track. Thanks for your help!
html code to collect user input for fields on the form.....
<?php>
if(isset($_POST['Submit'])) {
$FName = $_POST['FName'];
$MI = $_POST['MI'];
$LName = $_POST['LName'];
....
?>
<form action="" method="post">
<input type="submit" name="Submit" value="Submit">
I think it can be good to read a bit more about it. Check here.
Anyway, you need to say the name of the file to post to: <input type="submit" action="file.php" name="Submit" />
for example.
And you need to have more inputs than the submit.
Acording to your php you should have as example this in the html:
<form action="your_php_file.php" method="post">
<p>Your first name: <input type="text" name="FName" /></p>
<p>Your last name: <input type="text" name="LName" /></p>
<p>Your MI: <input type="text" name="MI" /></p>
<p><input type="submit" name="Submit"/></p>
</form>
And the php tags are like <?php
to open, and ?>
to close.
So like:
<?php
if(isset($_POST['Submit'])) {
$FName = $_POST['FName'];
$MI = $_POST['MI'];
$LName = $_POST['LName'];
//....
?>
Your PHP tags are incorrect. Use <?php
and ?>
to tell PHP to start and stop interpreting the code between them. Also, make sure you're closing the form
element (I only see you're opening it) using </form>
and that you indeed have all those fields contained inside of it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With