Lost content after submit form

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
Jeroen
New php-forum User
New php-forum User
Posts: 40
Joined: Fri Aug 10, 2012 4:37 pm
Contact:

Tue Sep 11, 2012 7:34 am

It is a big guess, as there is no actual code posted that can cause your problem. But this is my guess:

You need to sanitize your data before putting it in your database:

Code: Select all

if(isset($_POST["submit"]))
{
   $txtName = mysql_real_escape_string($_REQUEST['txtName']);
 //or (not so save)
   $txtEmail = htmlspecialchars($_REQUEST['txtEmail'], ENT_QUOTES);
 // DONT do this
   $txtContent = addslashes($_REQUEST['txtContent']);   
         
        // Insert data to database
}
Better is to use prepare statements, you can do that with mysqli or PDO

Post Reply
  • Information
  • Who is online

    Users browsing this forum: hyper and 3 guests