Jump to content

Simple input for Data Base


Jay2391

Recommended Posts

All I am trying to do is to input data from a PHP page to my database but it is not working looking for a new set of eyes...

Database:  mainlydigital
Table: users
server: localhost
hot id: host
pass: 12345
>:(

<HTML>
<head>
<title>MD Register</title></head>
<body>

<?php
$self = $_SERVER['PHP_SELF'];
$userid = $_POST['userid'];
$name = $_POST['name'];
$last = $_POST['last'];
$email = $_POST['email'];
$state = $_POST['state'];
$country = $_POST['country'];
$accname = $_POST['accname'];
$password = $_POST['password'];
$code = $_POST['code'];
$news = $_POST['news'];
$agreed = $_POST['agreed'];
$domain = "localhost";
$user = "root";
$pass = "12345";


if( $userid and $name and $last and $email and $state and $country and $accname and $password and $code and $news and $agreed){

    $conn = mysql_connect($domain, $user, $pass);

    $rs = mysql_select_db("mainlydigital", $conn) or die( "Err:Db" );

    $sql = "insert into users (userid, name, last, email, state, country, accname, password, code, news, agreed) values ( $userid, \"$name\", \"$last\", \"$email\", \"$state\", \"$country\", \"$accname\", \"$password\", \"$passwordv\", \"$code\", \"$news\", \"$agreed\")";

    $rs = @mysql_query( $sql, $conn );

        if( $rs ){
        echo( "Record added:$userid <br> $name <br> $last" );
        }
}

?>

<form
          action="<?php echo( $self ); ?>" method="post"><br>
          ID: <input type="text" name="id" size="3"><br>
          First Name: <input type="text" name="name" size="30">
          Last Name: <input type="text" name="last" size="30"><br>
          E-Mail:<input type="text" name="email" size="50"><br>
          City & State: <input type="text" name="state" size="30">
          Country: <input type="text" name="country" size="30"><br><br>
          Account Name: <input type="text" name="accname" size="30"><br><br>
          Enter Password (8 to 12 Characters):<br><input type="text" name="password" size="30"><br>
          Enter a four Digit Numeric Code:<br><input type="text" name="code" size="30"><br><br>
          Will you like email news about this site:<br><input type="text" name="news" size="30"><br>
          Confirm you have read all the rules and regulations <br>and you
          agreed to obey by those:<br><input type="text" name="agreed" size="30"><br>

<br><br>
<input type="submit" value="Register">
</form>
</body>
</HTML>

Link to comment
Share on other sites

mismatch in number of cols compared to variables in query - missing "passwordv"

$sql = mysql_query("insert into users (userid, name, last, email, state, country, accname, password, [red]passwordv[/red], code, news, agreed) values ('$userid', '$name', '$last', '$email', '$state', '$country', '$accname', '$password', '$passwordv', '$code', '$news', '$agreed')") or die(mysql_error());

But if userid is auto incr primary key, you should also remove this
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.