Jump to content

Recommended Posts

Hi all,

 

Come across a strange issue and I'm not sure how to solve it.

 

I've a form that asks if a user wants to save the details until next time.  The problem is that if there are no cookies set it displays html in the table fields that the user has to delete.  This was working fine but I've changed so many things I can't think of what it could be.

 

I've this in the php

 

        //save the details as a cookiiiiie if selsected
        $saveDetails = $_POST['saveDetails'];
        if($saveDetails == 'on'){
            setcookie("cookieUserName", $_POST['name'], time()+60*60*24*365);
            setcookie("cookieUserEmail", $_POST['email'], time()+60*60*24*365);
            setcookie("cookieUserCompany", $_POST['companyName'], time()+60*60*24*365);
            setcookie("cookieUserContact", $_POST['contactNumber'], time()+60*60*24*365);
        }
 
and then in the form itself:
 
<form action="" method="post" id="ourContactFormID_JS">
 
             <input type="hidden" name="token" value="<?php echo $newToken; ?>">
 
             <div class="ourContactFormElement">
                 <label for="name"><span class="requiredField">*</span>Your Name:</label>
                 <input type="text" id="name" name="name" class="required" value="<?php echo $_COOKIE["cookieUserName"]; ?>" <?php if(isset($_POST['name'])){ echo 'value="', htmlspecialchars($_POST['name'], ENT_QUOTES, 'UTF-8'), '"';}  ?> />
             </div>
 
             <div class="ourContactFormElement">
                 <label>   </label>
                 <input type="submit" value="Send Request!" />
             </div>
 
             <div class="ourContactFormElement">
                 <label>   </label>
                 <input type="checkbox" name="saveDetails" />
                 <label for="saveDetails">  Save Contact Details?</label>
             </div>
 
</form>

 

 

When using firebug on the element I can se all the html.  this is the first line:

<input class="required email jqtranformdone jqTransformInput error" type="text" value="<br><table border='1'

 

You can see that it starts from where the 'value=' is.

I've removed that line from my form and it displays fine so that is definitely the issue but it's a feature that I'd like to keep, any ideas?

I'm sure there's a better way but in the meantime I've used:

 

 

<?php
//is there a better way? Sets the cookies to be null values so html markup is not
//presented the first time a page is loaded
setcookie("cookieUserEmail",' ');
setcookie("cookieUserName",' ');
setcookie("cookieUserCompany",' ');
setcookie("cookieUserContact",' ');?>
<?php
 
at the very top of the page to solve the issue.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.