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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:17:30+00:00 2026-05-26T11:17:30+00:00

I created a database with user’s first name, last name, email, and temp password.

  • 0

I created a database with user’s first name, last name, email, and temp password. When a user logs in for the first time they are shown a profile with the information already in the database as well as some additional fields they must fill in. On clicking submit the form should then update their profile in the database but it doesn’t. The database is called ‘users’. Could someone please tell me what I’m doing wrong?

 <?php
$testerID = preg_replace('#[^0-9]#i', '', $_SESSION["id"]); // filter everything but numbers and letters
$tester = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["tester"]); // filter everything but numbers and letters
$password = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["password"]); // filter everything but numbers and letters

include "scripts/connect_to_mysql.php"; 
    $sql = mysql_query("SELECT * FROM users WHERE id='$testerID' AND username='$tester' AND password='$password' LIMIT 1"); // query the person
    $row = mysql_fetch_array($sql);
    $fname = $row['fname'];
    $lname = $row['lname'];
    $email = $row['email'];

$existCount = mysql_num_rows($sql); // count the row nums
if ($existCount == 0) { // evaluate the count
     echo "Your login session data is not on record in the database.";
     exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tester Home</title>
</head>

<body>
<table width="886">
  <tr>
    <td width="876"><h1>Welcome 
    <?php  
    echo $fname;
    ?> 
    to the Closed Beta</h1></td>
  </tr>
</table>
<p>&nbsp;</p>
<div id="content">
<?php
$date = getdate();
// Parse the form data and add inventory item to the system
if (isset($_POST['$new_password'])) {
    $new_email = mysql_real_escape_string($_POST['email']);
    $new_password = mysql_real_escape_string($_POST['new_password']);
    $phone_model = mysql_real_escape_string($_POST['phone_model']);
    $carrier = mysql_real_escape_string($_POST['carrier']);

    $sql_update = mysql_query("UPDATE users SET email='$new_email', password='$new_password', phone_model='$phone_model', carrier='$carrier' WHERE id='$testerID'");
}
if(is_null($test_start)){ 
    echo "
    <form action=\"index.php\" enctype=\"multipart/form-data\" name=\"myForm\" id=\"myform\" method=\"post\">
    <table width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"6\">
      <tr>
        <td width=\"20%\" align=\"right\">ID: </td>
        <td width=\"80%\"><label>
          $testerID 
        </label></td>
      </tr>
      <tr>
        <td align=\"right\">Username: </td>
        <td><label>
          $tester
          </label></td>
      </tr>
      <tr>
        <td align=\"right\">First Name: </td>
        <td><label>
          $fname
          </label></td>
      </tr>
      <tr>
        <td align=\"right\">Last Name: </td>
        <td><label>
          $lname
          </label></td>
      </tr>
      <tr>
        <td align=\"right\">Email Address: </td>
        <td><label>
          <input type=\"text\" name=\"email\" id=\"email\" value=\"\"/>
        </label></td>
      </tr>
      <tr>
        <td align=\"right\">Old password: (the one you were assigned)</td>
        <td><label>
          <input type=\"text\" name=\"old_password\" id=\"old_password\" value=\"$password\"/>
        </label></td>
      </tr>
      <tr>
        <td align=\"right\">New Password: </td>
        <td><label>
          <input type=\"text\" name=\"new_password\" id=\"newPassField\" />
        </label></td>
      </tr>
      <tr>
        <td align=\"right\">Confirm New Password: </td>
        <td><label>
          <input type=\"text\" name=\"confirm_password\" id=\"newPassField\" />
        </label></td>
      </tr>
      <tr>
        <td align=\"right\">Phone Model: </td>
        <td><label>
          <input type=\"text\" name=\"phone_model\" id=\"phone_model\" value=\"$phone_model\"/> (a 4 digit number)
        </label></td>
      </tr>
      <tr>
        <td align=\"right\">Carrier: </td>
        <td><label>
          <input type=\"text\" name=\"carrier\" id=\"carrier\" cols=\"64\" rows=\"5\" value=\"$carrier\"/>
          </label></td>
      </tr>
          <input type=\"submit\" name=\"button\" id=\"button\" value=\"Update\" />
    </table>
    </form>";   
}else{

}
?>
</div>
<p>&nbsp;</p>
</body>
</html>
  • 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-26T11:17:31+00:00Added an answer on May 26, 2026 at 11:17 am

    if there is an error in your sql then the best way to find out what it is, is to add in error checking code

    or die(mysql_error());
    

    i have added it to the end of your query here

    $sql_update = mysql_query("UPDATE users SET email='$new_email', password='$new_password', phone_model='$phone_model', carrier='$carrier' WHERE id='$testerID'") or die(mysql_error());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created few user defined types in my database as below CREATE TYPE [dbo].[StringID]
I have created one user named tuser with create database rights in SQL server
I've created a custom user control that has several properties. One specifies which database
I created new cPanel account, using this account created new database, new database user
python manage.py dumpdata modelName > file.json . created an empty database for a user
I created a user like this: create user blog with password 'blog'; Then I
I am using membership class for my user management, and it created a database
I have created database and user and give all the privilege to the user.When
I have already created a user database file using Apache's htpasswd command. This file
I have created one database and one table user in that while running my

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.