Note that there are some explanatory texts on larger screens.

plurals
  1. POUnexpected index on two variables in PHP form
    primarykey
    data
    text
    <p>So doing a simple registration into database, but the value of <code>First Name</code> and <code>Last Name</code> is getting unexpected index but account type <code>username</code> is fine.</p> <p>HTML code:</p> <pre><code>&lt;form method="post" enctype="multipart/form-data" action="signIn.php"&gt; &lt;h3&gt;Create Your Account&lt;/h3&gt; Account Type &lt;select name="accountType"&gt; &lt;option&gt;Rentors&lt;/option&gt; &lt;option&gt;Homeowners&lt;/option&gt; &lt;/select&gt; First Name: &lt;input type="text" name"Fname" size="40"&gt; Last Name: &lt;input type="text" name"Lname" size="40"&gt; User Name: &lt;input type="text" name="username" size="40"&gt; Password: &lt;input type="password" name="password" size="40"&gt; &lt;input type="submit" name="signInformSubmit" value="SIGN UP"&gt; &lt;/form&gt; </code></pre> <p>PHP code I have tried isset on the <code>varFirstName</code> and <code>varLastName</code> and still no values in the database.</p> <pre><code>if ( isset($_POST['signInformSubmit']) ) { $varAccountType = $_POST['accountType']; $varFirstName = isset($_POST['Fname']) ? $_POST['Fname']:''; $varLastName = isset($_POST['Lname']) ? $_POST['Lname']:''; $varUserName = $_POST['username']; $varPassword = $_POST['password']; } </code></pre> <p>/////////////////////connect and insert to database///////////////////</p> <pre><code>$mysqli = new mysqli("localhost","root","", "test"); if ($mysqli-&gt;connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli-&gt;connect_errno . ") " . $mysqli-&gt;connect_error; } /* Prepared statement, stage 1: prepare */ $stmt = $mysqli-&gt;prepare("INSERT INTO accounts (accountType, FirstName, LastName, UserName, Password) VALUES (?,?,?,?,?)"); /* Prepared statement, stage 2: bind and execute */ $stmt-&gt;bind_param('sssss', $varAccountType, $varFirstName, $varLastName, $varUserName, $varPassword); $stmt-&gt;execute(); /* explicit close recommended */ $stmt-&gt;close(); $mysqli-&gt;close(); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload