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

  • Home
  • SEARCH
  • 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 7962347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:18:40+00:00 2026-06-04T05:18:40+00:00

I have a form in my handler: <form action=../submitcomment.php method=post> <input maxlength=100 size=60 type=text

  • 0

I have a form in my handler:

<form action="../submitcomment.php" method="post">
                <input maxlength=100 size=60 type="text" name="IP" value="' . $ip . '" readonly="readonly" hidden="hidden">
                <input maxlength=100 size=60 type="text" name="BlogId" value="' . $blogId . '" readonly="readonly" hidden="hidden">
                <input maxlength=100 size=60 type="text" name="Date" value="' . $date . '" readonly="readonly" hidden="hidden">         
                <input maxlength=100 size=60 type="text" name="Name" placeholder="Enter Your Name">
                <input maxlength=100 size=60 type="text" name="Email" placeholder="Enter Your Email">
                <input maxlength=100 size=60 type="text" name="Comment" placeholder="Enter Your Comment">
                <br>
                <input type="submit" name="Submit" value="Submit Your Comment">
                </form>

The action is submitcomment.php:

$ip = $_POST['IP'];
$BlogId = $_POST['BlogId'];
$Date = $_POST['Date'];
$Name = $_POST['Name'];
$Email = $_POST['Email'];
$Comment = $_POST['Comment'];

$blog = new Blogs();

if (isset($_POST['Submit'])) 
{
    $addComment = $blog->insertComment($ip, $BlogId, $Date, $Name, $Email, $Comment);
    header('Location: http://www.ryan.archi.dev.netsite.co.uk/Blog?success=1');
}else{
    header('Location: http://www.ryan.archi.dev.netsite.co.uk/Blog?fail=1');
}

which reference a function in my class:

function insertComment($ip, $BlogId, $Date, $Name, $Email, $Comment)
    {
        $query = "INSERT INTO BlogComments (Name, Comment, IPAddress, Email, BlogId, Date) VALUES ('$Name', '$Comment', '$ip', '$Email', '$BlogId', '$Date')";
        $oDatabase = new database;
        $connection = $oDatabase->Connect();
        $result = mysql_query ($query, $connection);
        return $result;
    }

The attempt to insert does not return or raise any errors.
As far as I’m aware this should be working, Can you spot what I am doing wrong?

  • 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-06-04T05:18:41+00:00Added an answer on June 4, 2026 at 5:18 am

    Problem is with the column named Date – date is a reserved word (I guess of all known RDBMS).

    You have to escape this word in Your query:

    INSERT INTO BlogComments (Name, Comment, IPAddress, Email, BlogId, `Date`) VALUES ('$Name', '$Comment', '$ip', '$Email', '$BlogId', '$Date')
    

    Also Your code gives anybody a chance to do a SQL injection attack therefore You should at least escape any user input or better use MySQLi or PDO.

    You can do the escaping by php function http://php.net/mysql_real_escape_string :

    $ip = mysql_real_escape_string($_POST['IP']);
    $BlogId = mysql_real_escape_string($_POST['BlogId']);
    $Date = mysql_real_escape_string($_POST['Date']);
    $Name = mysql_real_escape_string($_POST['Name']);
    $Email = mysql_real_escape_string($_POST['Email']);
    $Comment = mysql_real_escape_string($_POST['Comment']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried to different ways to clear a form: <form action=service.php id=addRunner name=addRunner
I have a line of code that reads as follows :- <input type='button' name='p_send'
I have a form, and a submit handler in jQuery. When the user submits
I have an event handler for the TextBox.TextChanged event on a form of mine.
I have a form with an input element but no submit button. I use
I have a form in my HTML page, containing a label, an input field
I have a drag-and-drop event handler registered to a parent form, this.DragDrop += new
I am getting a new php warning when a POST data from a form
I have a form field and i want to read the text entered into
I have a form that handles editing of a domain model (A). This domain

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.