Jump to content

Recommended Posts

I've been struggling with this for hours and can't seem to understand how the quote syntax works.

Can someone tell me what is wrong and explain please? Much appreciated!

 

$form_output .= '<p><label for="email">Notification email (IMPORTANT!) <span>*</span><br><input type="text" name="email" value=" . 'echo $_POST' . "></label></p>';

you should be able to read this better...also using the echo where it is, is incorrect.

$form_output = '<p><label for="email">Notification email (IMPORTANT!) <span>*</span><br><input type="text" name="email" value="' 
               . $_POST["email"] 
               . '"></label></p>';

this should do the trick

Edited by Destramic

  • You want your single and double quotes to be nested like HTML tags.

Don't put quotes next to your variables, but a period to append it to some text.

Echo is to display on the page.  You don't echo the variables when assigning to a string.

.= is to append versus just = to replace the variable.

also what i forgot to mention is that if your using user inputted data ie. $_POST then you need to escape it using

$_POST['email'] = htmlspecialchars($_POST['email'], ENT_QUOTES, 'UTF-8');

your code is vulnerable to cross site scripting attacks (XXS)

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.