Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6221461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:08:14+00:00 2026-05-24T08:08:14+00:00

After being advised that i MUST validate my form so that no-one could hack

  • 0

After being advised that i MUST validate my form so that no-one could hack my database i then made some changes which were adding the mysql_real_string()

$query="INSERT INTO allymccoist (id, firstname, lastname, email, date) 
VALUES (NULL, '".$firstname."', '".$lastname."', '".$email."',   '".mysql_real_escape_string($new_date)."')";

$firstname = mysql_real_escape_string($_POST['firstname']);
$lastname = mysql_real_escape_string($_POST['lastname']);
$email = mysql_real_escape_string($_POST['email']);
$datepicker = mysql_real_escape_string($_POST['date']);

since doing this, nothing is being sent to firstname lastname or email although the date seems to be sending ok though

is thereanything that may be causing this that you can see from my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:08:16+00:00Added an answer on May 24, 2026 at 8:08 am

    If you’re sure that those data actually are set (var_dump your $_POST array to check that),then make sure you have a connection active before using mysql_real_escape_string(), as it would return FALSE otherwise:

    A MySQL connection is required before using mysql_real_escape_string()
    otherwise an error of level E_WARNING is generated, and FALSE is
    returned. If link_identifier isn’t defined, the last MySQL connection
    is used.

    So you can well be entering FALSE in every value.

    $link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')or die(mysql_error());
    mysql_select_db('database_name', $link) or die('cannot select database '.mysql_error());
    
    $firstname = mysql_real_escape_string($_POST['firstname']);
    $lastname = mysql_real_escape_string($_POST['lastname']);
    $email = mysql_real_escape_string($_POST['email']);
    $datepicker = mysql_real_escape_string($_POST['date']);
    

    You’d be better off altogether by using prepared statements, so you won’t have to worry about SQL injections.

    Also, I’d advice you against using NULL in your insert query for the field ID. If you’re table is strcutred as I can guess, and ID is a primary key with AutoIncrement, you don’t need to enter it in your query, as it would be automatically filled by the engine.

    For wheter it is better to use prepared statements or mysql_real_escape_string(), check this resource mysql_real_escape_string vs prepared statements

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After being advised that the native ComboBox was not the way to go I
I'm trying to write a decorator that 'refreshes' after being called, but where the
The data was inserted into the database after being escaped as follows: $caller=htmlentities($formVarsI['caller'], ENT_QUOTES,
After being told by at least 10 people on SO that version control was
After being troubled by an issue that I simply did not have the knowledge
After being frustrated in my attempts to learn the arcana that is ASP.NET, I
Here is my code that should display two full dates after being passed timestamps:
After being stumped by an earlier quesiton: SO google-analytics-domain-data-without-filtering I've been experimenting with a
After being blown away by the greatness of irb and rails console, I am
I want to display the column 'name' after being found from the table mytest.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.