Jump to content

Recommended Posts

ok In my installation process, I wanted the user to be able to add their own username and password with admin rights.

 

I have a form that will allow them to do this, but I cannot get it to take the information from the form and add it to the database.

 

How can I do this?

 

here is my form script

 

<!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=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<h1>Creating Admin Account (Step 3 of 3)</h1>
<p>this will create your user name and password to the website's database, this will able you to run the website, just login as this username, and password </p>
<form id="form1" name="form1" method="post" action="action.php">
  <table width="75%" border="0" cellspacing="1" cellpadding="1">
    <tr>
      <td width="23%">Administration's User Name </td>
      <td width="22%"><input name="username" type="text" id="username" size="30" maxlength="50" /></td>
      <td width="55%"> </td>
    </tr>
    <tr>
      <td>Administration's Password </td>
      <td><input name="password" type="password" id="password" size="30" maxlength="50" /></td>
      <td> </td>
    </tr>
    <tr>
      <td>Administration's E-Mail </td>
      <td><input name="email" type="text" id="email" size="30" maxlength="50" /></td>
      <td> </td>
    </tr>
    <tr>
      <td><input name="userid" type="hidden" id="userid" value="1" />
      <input name="userlevel" type="hidden" id="userlevel" value="1" /></td>
      <td><input type="submit" name="Submit" value="Finish" />
      <input name="reset" type="reset" id="reset" value="Reset" /></td>
      <td> </td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
  </table>
</form>
<p> </p>
</body>
</html>

 

here is my action.php, it is suppose to add info to the database

<?php
if(isset($_POST['submit']))
include ("../_bin_/config.php");
{//begin of if($submit).

      // Set global variables to easier names

     // and pervent sql injection and apostrophe to break the db.

      $user = mysql_escape_string($_POST['username']);

      $pass = mysql_escape_string($_POST['password']);

      $ulvl = mysql_escape_string($_POST['userlevel']);
  
  $uid = mysql_escape_string($_POST['userid']);
  
  $emil = mysql_escape_string($_POST['email']);


include ("../_bin_/config.php");
// connect to the mysql server
$link = mysql_connect($DB_SERVER, $DB_USER, $DB_PASS)
or die ("Could not connect to mysql because ".mysql_error());

// select the database
mysql_select_db($DB_NAME)
or die ("Could not select database because ".mysql_error());
//run the query which adds the data gathered from the form into the database

         $result = mysql_query("INSERT INTO users (username, password, userlevel, userid, email");

                      

          //print success message.

          echo "<meta http-equiv=Refresh content=1;url=finish.php>";

  }
  ?>

 

any suggestions?

 

I need to add this info to the database "websitedb" under the table "users"

 

Username, Password, Email, UserID, Userlevel.

 

How?

Link to comment
https://forums.phpfreaks.com/topic/77856-adding-values-to-fields-under-a-table/
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.