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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:51:52+00:00 2026-06-09T05:51:52+00:00

I am trying to make a form using html and php to update mysql

  • 0

I am trying to make a form using html and php to update mysql database. the database updates (autoincrements) the keys, but it does not add any of the strings to the values. i have searched people with similar problems but because their codes are different than mine I cannot understand it (i am a noob with php and mysql) I think my problem is in the way that i use the html to get the values but I could be wrong

<form action=submitform.php method=GET> 
     Name:<input type="text" name="cuName" size=20 maxlength=20><br>    
     Password:<input type="password" name="password" size=20 maxlength=45><br>
     Account:<input type="text" name="account" size=20 maxlength=45><br>
     Phone:<input type="tel" name="phone" size=10 maxlength=10><br>
     Email:<input type="text" name="email" size=20 maxlength=45><br>
<input type=submit>
</form>

and my php is

<?php
        mysql_connect(localhost,  myUsername, "myPassword");
        mysql_select_db(myDatabaseName);
        mysql_query("INSERT INTO Customer (cuName, password, 
                        account, phone, email)
                    Values('$cuName', '$password', '$account',
                            '$phone', '$email')");
        echo $cuName ." thank you for reserving!";
        print ($cuName);
    ?>

thanks in advance for any 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-09T05:51:53+00:00Added an answer on June 9, 2026 at 5:51 am

    Your code is relying on REGISTER_GLOBALS to be turned on; it is usually turned off for security reasons.

    You should replace $cuName with $_GET['cuName'] to get the values that are sent from the form.

    Additionally, you should escape any value that is going to the database otherwise you may be exposing yourself to an SQL injection vulnerability.

    Cleaning up your code for both these scenarios, results in something like this:

    <?php
            if (!mysql_connect(localhost,  myUsername, "myPassword")) {
                  print 'There was an error connecting to the database'.mysql_error();
                  exit(); 
            }
            if (!mysql_select_db(myDatabaseName)) { 
                  print 'Could not select db. The error was: '.mysql_error();
                  exit();
            }
            $query = "INSERT INTO Customer (`cuName`, `password`, `account`,`phone`,`email`)";
            $query .= "VALUES (";
            $query .= "'".mysql_real_escape_string($_GET['cuName'])."','";
            $query .= mysql_real_escape_string($_GET['password'])."','";
            $query .= mysql_real_escape_string($_GET['phone'])."','";
            $query .= mysql_real_escape_string($_GET['email'])."'";
    
            if (!mysql_query($query)) {
                print 'There was an error inserting '.$query.'. Error was '.mysql_error();
            } else {
                echo $_GET['cuName']." thank you for reserving!";
            }
            print $_GET['cuName'];
        ?>
    

    I also added some error checking. You should always check results of functions that rely on external systems (such as databases) because you never know what is the status of the database (it could be down, not working, etc.) So you should always check and print any error messages.

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

Sidebar

Related Questions

I'm trying to make a simple form, but it's working not so fine. This
I'm trying to make a form to login users into my webpage using mysql
I'm using the following code in my HTML form - trying to make a
Possible Duplicate: PHP MySQL multiple search query using option / select HTML form tags
I am trying to make a form using two drop down select menus: one
I am trying to make an input form have a background image, but as
I'm trying to make an AJAX form that will update a twitter status when
I'm trying to upload a picture to a specific website using php cURL but
I'm trying to make an auto-login using Greasemonkey. Can anyone help me? Relevant HTML
I am trying to work on getting better at making HTML forms using PHP

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.