Note that there are some explanatory texts on larger screens.

plurals
  1. POStoring form data with PHP Session
    primarykey
    data
    text
    <p>I am working on an HTML form whose data would be saved on a failed submit, or page refresh.</p> <p>We are using a PHP Session to store this data, and we post the elements back when needed. </p> <p>The issue is that it's not working. We need the form data to be preserved on a submit with errors, or page refresh. Currently on a failed submit, or page refresh, there is no data being stored in the session.</p> <p>I'm fairly new to PHP, and most of this code is not mine, so go easy on me.</p> <p>The PHP Sumbit code being used is:</p> <pre><code>Software: PHPMailer - PHP email class Version: 5.0.2 Contact: via sourceforge.net support pages (also www.codeworxtech.com) Info: http://phpmailer.sourceforge.net Support: http://sourceforge.net/projects/phpmailer/ </code></pre> <p>SESSION: </p> <pre><code>&lt;?php session_name("fancyform"); session_start(); $str=''; if($_SESSION['errStr']) { $str='&lt;div class="error"&gt;'.$_SESSION['errStr'].'&lt;/div&gt;'; unset($_SESSION['errStr']); } $success=''; if($_SESSION['sent']) { $success='&lt;div class="message-sent"&gt;&lt;p&gt;Message was sent successfully. Thank you! &lt;/p&gt;&lt;/div&gt;'; $css='&lt;style type="text/css"&gt;#contact-form{display:none;}&lt;/style&gt;'; unset($_SESSION['sent']); } ?&gt; </code></pre> <p>FORM:</p> <pre><code>&lt;form id="contact-form" name="contact-form" method="post" action="submit.php"&gt; &lt;p&gt;&lt;input type="text" name="name" id="name" class="validate[required]" placeholder="Enter your first and last name here" value="&lt;?=$_SESSION['post']['name']?&gt;" /&gt;&lt;/p&gt; &lt;p&gt;&lt;input type="text" name="email" id="email" class="validate[required,custom[email]]" placeholder="Enter your email address here" value="&lt;?=$_SESSION['post']['email']?&gt;" /&gt;&lt;/p&gt; &lt;p&gt;&lt;input type="text" name="phone" id="phone" placeholder="Enter your phone number here" value="&lt;?=$_SESSION['post']['phone']?&gt;" /&gt;&lt;/p&gt; &lt;p&gt; &lt;select name="subject" id="subject"&gt; &lt;option&gt;What event service are you primarily interested in?&lt;/option&gt; &lt;option&gt;Event Creation&lt;/option&gt; &lt;option&gt;Project Management&lt;/option&gt; &lt;option&gt;Promotion&lt;/option&gt; &lt;/select&gt; &lt;/p&gt; &lt;textarea name="message" id="message" class="validate[required]" placeholder="Please include some details about your project or event..."&gt;&lt;?=$_SESSION['post']['message']?&gt; &lt;/textarea&gt; &lt;input type="submit" value="" /&gt; &lt;/form&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