Note that there are some explanatory texts on larger screens.

plurals
  1. PONot writing to db
    primarykey
    data
    text
    <p>I've been here many times. I cannot get info to post to database. Can someone explain to me what im doing wrong so I can resolve the issue?</p> <p>I've ran the code on a local host with E_All and E_strict and the only thing that comes up is undefined variables. Not the ones that are supposed to be posting but the username/pass/db name ones.</p> <p>First is the Form I am using and the second is the php.</p> <pre><code>&lt;form method="post" action="hg.php"&gt; &lt;div id="box"&gt; &lt;font size="1px"&gt; Winner must be 18 years or older and have a valid email address. Drawings will be held 12/31/2013. If for any reason either winners do not claim prize within 30 days, that winner will be null and void and we will draw again on 01/31/14 for that winners prize choices. If no winner claims their prize within 30 days from 01/31/14, all drawings and winners will be forfeit except for the already claimed prizes if any. &lt;/font&gt;&lt;/div&gt; &lt;div class="clear"&gt; &lt;/div&gt; &lt;div id="box"&gt; &lt;label for="textfield" style="margin-top:15px;"&gt;First Name&lt;/label&gt; &lt;input id="textfield" type="text" name="first" /&gt; &lt;/div&gt; &lt;div id="box"&gt; &lt;label for="textfield" style="margin-top:15px;"&gt;Last Name&lt;/label&gt; &lt;input id="textfield" type="text" name="last" /&gt; &lt;/div&gt; &lt;div class="clear"&gt; &lt;/div&gt; &lt;div id="box"&gt; &lt;label for="textfield"&gt;Phone&lt;/label&gt; &lt;input id="textfield" type="text" size="13" maxlength="13" name="contact" /&gt; &lt;/div&gt; &lt;div id="box"&gt; &lt;label for="textfield" style="margin-left:15px;"&gt;Email&lt;/label&gt; &lt;input id="textfield" type="text" name="email" style="margin-left:15px;"/&gt; &lt;/div&gt; &lt;div class="clear"&gt; &lt;/div&gt; &lt;div id="box"&gt; &lt;label for="textfield"&gt;Date of Birth&lt;/label&gt; &lt;input id="textfield" type="text" name="dob" /&gt; &lt;/div&gt; &lt;div class="clear"&gt; &lt;/div&gt; &lt;div id="box"&gt;&lt;input type="submit" value="Register" id="submit"&gt;&lt;/div&gt; &lt;/form&gt; </code></pre> <p>the php</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;?php $first = $_POST['first']; $last= $_POST['last']; $contact = $_POST['contact']; $email = $_POST['email']; $dob = $_POST['dob']; $host = 'localhost'; $db_name= 'rebeler_email'; $db_username = 'rebeler_email'; $db_password = 'callaway87'; if(isset($_POST['submit'])) { $pdo = new PDO('mysql:host='.$host.';dbname='.$db_name, $db_username, $db_password); $statement = $pdo-&gt;prepare(' INSERT INTO `email`( `email`, `first`, `last`, `contact`, `dob` ) VALUES ( :email, :first, :last, :contact, :dob ) '); $result-&gt;execute('array( `email`=&gt;$_POST[`email`], `first`=&gt;$_POST[`first`], `last`=&gt;$_POST[`last`], `contact`=&gt;$_POST[`contact`], `dob`=&gt;$_POST[`dob`] )'); $email_id = $pdo-&gt;lastInsertId(); if (!result || !$customer_id) { var_dump($pdo-&gt;errorInfo()); die('something went wrong'); // do something better to handle errors! } } ?&gt; &lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" type="text/css" href="css.css"&gt; &lt;style type="text/css"&gt; #hgtitle{ height: 50px; width: 300px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;a href="new.html"&gt;&lt;img src="images/hgtitle.jpg" id="hgtitle"&gt;&lt;/a&gt; &lt;div id="box"&gt; Thank you for registering. &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    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.
    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