Jump to content

PHP Forms


Irksome

Recommended Posts

Hi all - I've become stuck in my attempt at making a register form for my site, so I have two quick questions to ask.

 

1) I have my register and login systems working fine, but the signup form only has one password box. I want to make a "confirm password" field as well, but have no real idea on how to do that. Maybe a quick Java script or something?

 

Here's the code for the signup page:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form1" method="post" action="register.php">
  <table width="100%" border="0" cellpadding="4" cellspacing="0">
    <tr> 
      <td width="24%" align="left" valign="top">First Name</td>
      <td width="76%"><input name="first_name" type="text" id="first_name"></td>
    </tr>
    <tr> 
      <td align="left" valign="top">Last Name</td>
      <td><input name="last_name" type="text" id="last_name"></td>
    </tr>
    <tr> 
      <td align="left" valign="top">Email Address</td>
      <td><input name="email_address" type="text" id="email_address"></td>
    </tr>
    <tr> 
      <td align="left" valign="top">Desired Username</td>
      <td><input name="username" type="text" id="username"></td>
    </tr>
    <tr> 
      <td align="left" valign="top">Desired Password</td>
      <td><input name="password" type="password" id="password"></td>
    </tr>
    <tr> 
      <td align="left" valign="top">Information about you</td>
      <td><textarea name="info" cols="45" rows="5" id="info"></textarea></td>
    </tr>
    <tr> 
      <td align="left" valign="top"> </td>
      <td><input type="submit" name="Submit" value="Submit"></td>
    </tr>
  </table>
</form>
</body>
</html>

 

2) I have tried to create an update profile page, but it has just failed miderably. I get SQL errors every time I click submit. No idea what's wrong here:

 

<?

include 'db.php';

// Define variables
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$password = $_POST['password'];
$info = $_POST['info'];
$userid = $_POST['userid'];

/* stripslash check*/

$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email_address = stripslashes($email_address);
$info = stripslashes($info);
$userid = stripslashes($userid);
$password = stripslashes($password);


/* Error checking */

if((!$first_name) || (!$last_name)){
echo 'You did not submit the following required information! <br />';
if(!$first_name){
	echo "First Name is a required field. Please enter it below.<br />";
}
if(!$last_name){
	echo "Last Name is a required field. Please enter it below.<br />";
}
include 'update_profile.php'; // re-display form
/* If everything is ok create the account. */
exit(); // exit script if error checking fials
}

/* Both error check passed. Update the profile. */

$db_password = md5($password);

// Update DB
$info2 = htmlspecialchars($info);
$sql = mysql_query("UPDATE com_users SET first_name='$first_name', last_name='$last_name', email_address='$email_address', username='$username', password='$db_password', info='$info' WHERE userid='$userid' ");

if(!$sql){
echo 'There has been an error updating your account. Please contact the webmaster.';
} else {
$userid = mysql_insert_id();
}

?>

 

Any help on these issues would be very much appreciated.

 

Thank you.

Link to comment
Share on other sites

 

solution1--

<tr>

      <td align="left" valign="top">Desired Password</td>

      <td><input name="password" type="password" id="password"></td>

    </tr>

<tr>

      <td align="left" valign="top">Confirm  Password</td>

      <td><input name="password2" type="password" id="password"></td>

    </tr>

 

solution2

 

check the condition

if(password1!=password2)then display error message

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.