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 8136117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:39:06+00:00 2026-06-06T10:39:06+00:00

it validates and displays the errors in my arrays properly, however it doesn’t POST

  • 0

it validates and displays the errors in my arrays properly, however it doesn’t POST to my database. All the naming of fields is correct on the form (case correct too), PHP, and MYSQL, dbconnect.php are all correct and proper. The problem i believe is somewhere in the array function. Now I just started learning PHP this month so please go easy on me. Thanks for the help!

<?php
include ('scripts/dbconnect.php');
$Name = mysql_real_escape_string($Name);
$Email = mysql_real_escape_string($Email);

if (isset($_POST['formsubmitted'])) {
$error = array();//Declare An Array to store any error message  

if (empty($_POST['Name'])) {//if no name has been supplied 
    $error[] = 'Please Enter Your Name ';//add to array "error"
    } else {
        $Name = $_POST['Name'];//else assign it a variable
    }

if (preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $_POST['Email'])) { //regular expression for email validation
    $Email = $_POST['Email'];
    } else {
         $error[] = 'Your EMail Address is Invalid  ';
    }
}
if (empty($error)) //Send to database if no errors
    mysql_query("INSERT INTO InviteRequestDB ( 'Name', 'Email' ) VALUES ( '$Name', '$Email' )");
    mysql_close($connect); //Close connection to database

  foreach ($error as $key => $values) {
  echo "<li style=color:#FFF> $values </li>";
  }

?>

Now I know I shouldn’t be using mysql. But I ran into too many problems with mysqli and this is just a simple contact form.

Also should I be doing mysql_real_escape_string on each variable as i am doing now? Or is the order of the procedure not correct?

<form action="applyforinvite.php" method="post">
    <input class="textbox" type="text" name="Name" />
    <input class="textbox" type="text" name="Email" />
  <input type="hidden" name="formsubmitted" value="TRUE" />
  <input type="submit" value="Register" />
</form>

Thanks for the help!

  • 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-06T10:39:07+00:00Added an answer on June 6, 2026 at 10:39 am

    You shouldn’t quote the column names in the INSERT query. (‘name, ’email’) should be (name, email).

    Also, don’t use the php_mysql extension for new applications, it’s deprecated. Try MySQLi or PDO.

    Final edit( lol ), try this — fixed the multiple issues with the code:

        if (isset($_POST['formsubmitted'])) {
            $error = array(); //Declare An Array to store any error message  
    
            if (empty($_POST['Name'])) { //if no name has been supplied 
                $error[] = 'Please Enter Your Name '; //add to array "error"
            } else {
                $Name = mysql_real_escape_string($_POST['Name']); //else assign it a variable
            }
    
            if (preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $_POST['Email'])) { //regular expression for email validation
                $Email = mysql_real_escape_string($_POST['Email']);
            } else {
                $error[] = 'Your EMail Address is Invalid  ';
            }
            if (empty($error)) //Send to database if no errors
                {
                mysql_query("INSERT INTO InviteRequestDB (Name, Email) VALUES ( '$Name', '$Email' )");
            }
        }
    
        mysql_close($connect); //Close connection to database
    
        foreach ($error as $key => $values) {
            echo "<li style=color:#FFF> $values </li>";
        }
    

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

Sidebar

Related Questions

I have a form which when submitted(empty fields) displays spring validated errors in the
I've written a JavaScript function which validates form input and highlights the input fields
I have a script which validates each stage of a form and adds a
I have an controller that returns JSON. It takes a form, which validates itself
I have code that opens a dialog, validates, and posts a form when the
I have a series of input forms, all of them take a different form
I have a django form that first validates its data through calling form.is_valid(). If
I'm trying to create a registration form with Rails. It's working, but it doesn't
After my form.Form validates the user input values I pass them to a separate
I have a registration form which displays a users Name (textbox), Email (textbox) and

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.