0

I have created a blog using PHP that submits a form into a MySQL databse. It works perfectly. What i want to know is how to get it to recognise when i've pressed enter to create a new line or to record a ' without getting a MySQL error. Basically i want to turn a normal submission form into a submission form like is used on this website.

<tr>
 <td>Blog Title:</td>
 <td><input type="text" id="edt" name="BlogTitle"></td>
</tr>
<tr>
 <td>Blog Content:</td>
 <td><textarea name="BlogCont" cols="50" rows="10" id="edt"></textarea></td>
</tr>
<tr>
 <td><input type="hidden" name="Name" value="<?=$_SESSION['Name']?>"></td>
 <td><input type="submit" id="but" value="Post"></td>
</tr>

Any help would be appreciated.

1
  • Try nl2br. As for the other thing, are you escaping your inputs properly before inserting them? Commented Jan 13, 2014 at 12:56

1 Answer 1

1

For new lines with enter use nl2br (manual), for apostrophe you have to escape it with mysql_real_escape_string (manual).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.