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">
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 theform
element (I only see you're opening it) using</form>
and that you indeed have all those fields contained inside of it.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:
And the php tags are like
<?php
to open, and?>
to close.So like: