Jump to content

Recommended Posts

Hi guys, as I said, this is more assistance than anything.

 

Here's my code for adding a "User" to my Database

 

<?
// Make mysql connection below
$mysql_conn = @mysql_connect("****", "*****", "******") or die("Could not connect to the Database, Please send us an e-mail in the contact section");\

@mysql_select_db("*******", $mysql_conn) or die("DataBase does not exist");


// prepare the form values for insert

$name = mysql_real_escape_string($_POST['name']);
$password = mysql_real_escape_string($_POST['password']);
$email = mysql_real_escape_string($_POST['email']);
$values = mysql_real_escape_string($_POST['value1' , 'value2' , 'value3' , 'value4' , 'value5' , 'value6' , 'value7' , 'value8' , 'value9' , 'value10']);

// now i'm going to insert all the values into the database

$sql = "INSERT INTO '****' ( 'name' , 'password' , 'email' , 'values' ) VALUES ('$name' , '$password' , '$email' , '$values')";
$res = mysql_query($sql) or die(mysql_error());

// now, i'm going to let people know when something has gone wrong, or if its gone right.

   if(!$res){
   echo "Had a bit of a problem with the database, please report this in the help section so that we can totally freak out and fix it.";
   } else {
   echo "Successfully added you as a member, now you can go and edit your account. First though, you will need to complete subscription in your email inbox";
   }
// that concludes the script, thanks for using this service. HAHA!! World domination will be mine. Soon....
   ?>

 

I just want to know if this would work? I'm especially not sure of the variable $values, I want lots of values stored in one field, and then recall it later as a list.

Link to comment
https://forums.phpfreaks.com/topic/85864-assistance-with-add-user-script/
Share on other sites

CPanel means a Control Panel, and it depends on what you mean.  Are you referring to a Hosting Site CPanel or a script's CPanel?  CMS Systems have their own types of CPanels, but if this is a script you made, then you need to code the registration and confirmations yourself.  There are tutorials on how to do that floating around.

This

 

"INSERT INTO '****' ( 'name' , 'password' , 'email' , 'values' )

 

Should be like

 

"INSERT INTO tablename ( name , password , email , values )

 

You can have as many values as you want

That should probably be:

 

"INSERT INTO `tablename` (`name`,`password`,`email`,`values`)

Not if you don't use reserved names.

 

This

 

"INSERT INTO '****' ( 'name' , 'password' , 'email' , 'values' )

 

Should be like

 

"INSERT INTO tablename ( name , password , email , values )

 

You can have as many values as you want

That should probably be:

 

"INSERT INTO `tablename` (`name`,`password`,`email`,`values`)

It's better practice to not use reserved names as well.

 

And you won't trash your DB, it just won't work.

 

It's better practice to encase them in backticks so you don't accidentally use a reserved name and trash your table/database.

Hmm it's debatable really. Whether a clear database schema with informative field names takes precedence over the practice of not using reserved names. I would vote that if a reserved name is the best descriptor of the field's contents then you should use it. But that may be because I encase all my table/field names in backticks and so I can use reserved names if I want without having to worry. Other people who don't follow this practice are limited.

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.