Jump to content

[SOLVED] What does this error mean?


forumnz

Recommended Posts

[code]<html>
<head>
<style type="text/css">
<!--
body {
font-family: Tahoma, Arial, sans-serif;
font-size: 12px;
font-weight: bold;
}
-->
</style>
<title>Account Creation System</title></head>
<body>

<?php
/// install file check
if (!file_exists("install.txt")){ die("Admin - Please run install first");};

/// import config
require("config.php");

/// connect to database
$con=mysql_connect($mysql_hst,$mysql_us,$mysql_ps);
if (!$con)
  {
  die('Could not connect: ' . mysql_error() . '<br /><br />Check your config file or contact your server support team.');
  };
 
/// select DB
if (!mysql_select_db($mysql_db, $con)){die ("Could not connect to the database you specified. Make sure it exists and is correctly named within config.php");};

/// active or create?
if ($_GET["activec"] == "true"){
$setact = "UPDATE members SET active = '1' WHERE username = '" . str_replace(' ','/space/',mysql_real_escape_string($_GET["usrc"])) . "'";
mysql_query($setact, $con);
die ('Account active<br /><br /><a href="index.html">Login Now!</a>');
};


///Thing goes here



/// check filled
if ($_POST["username"] == "") { die ("You did not enter a username");
if ($_POST["password"] == "") { die ("You did not enter a password");};
if ($_POST["password"] != $_POST["password_confirm"]) { die ("Your passwords don't match"); };
if ($conf == "yes"){if ($_POST["email"] == "") {die ("Site Admin is requested that you supply a valid email address. Please go back and try again");};
if ($_POST["age"] == "") { die ("You did not enter an age");};
if ($_POST["phone"] == "") { die ("You did not enter a phone number"); };
if ($_POST["area"] == "") { die ("You did not enter an area");};

//lowercase
$usernamel = strtolower($_POST[username]);
$usernamel = str_replace(' ','/space/',$usernamel);

/// check whether usrname exists
$extresult = mysql_query("SELECT * FROM members");
while($row = mysql_fetch_array($extresult))
  {
  if ($row[username] == $usernamel){die ('The username is already inuse. Please go back and try again<br /><br /><a href="create.html">Try Again</a>');};
  };

/// encode psswrd
$passenc = $_POST[password];
$passencon = base64_encode($passenc);

/// insert data under conditions
if ($conf == "yes"){$active = "0";} else { $active = "1"; };
$store = "INSERT INTO `members` (`id`, `username`, `password`, `active`, `age`, `phone`, `area`) VALUES ('', '" . mysql_real_escape_string($usernamel) . "', '" . $passencon . "', '" . $active . "')";
mysql_query($store, $con);

/// confirmation
$to = $_POST[email];
$subject = "Members Account";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: " . $sendmail;

$body = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Tahoma>Thank you for signing up to the members area at ' . $_SERVER['HTTP_HOST'] . '
<BR><BR>Click to activate your account: </FONT><A
href="http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?usrc=' . $_POST[username] . '&activec=true"><FONT face=Tahoma>http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '</FONT></A>
</DIV></BODY></HTML>';

if ($conf == "yes") {
mail($to, $subject, $body, $headers);
echo ("Thank you " . str_replace('/space/',' ',$usernamel) . " your account has been created. Please activate it using the email that has been sent to your address");
} else { echo ('Your account has been created and is also active. You may login now.<br /><br /><a href="index.html">Login Now!</a>');

?>
</body>
</html>[/code]
[code=php:0]
<html>
<head>
<style type="text/css">
<!--
body {
font-family: Tahoma, Arial, sans-serif;
font-size: 12px;
font-weight: bold;
}
-->
</style>
<title>Account Creation System</title></head>
<body>

<?php
/// install file check
if (!file_exists("install.txt")){ die("Admin - Please run install first");};

/// import config
require("config.php");

/// connect to database
$con=mysql_connect($mysql_hst,$mysql_us,$mysql_ps);
if (!$con)
  {
  die('Could not connect: ' . mysql_error() . '<br /><br />Check your config file or contact your server support team.');
  };
 
/// select DB
if (!mysql_select_db($mysql_db, $con)){die ("Could not connect to the database you specified. Make sure it exists and is correctly named within config.php");};

/// active or create?
if ($_GET["activec"] == "true"){
$setact = "UPDATE members SET active = '1' WHERE username = '" . str_replace(' ','/space/',mysql_real_escape_string($_GET["usrc"])) . "'";
mysql_query($setact, $con);
die ('Account active<br /><br /><a href="index.html">Login Now!</a>');
};


///Thing goes here



/// check filled
if ($_POST["username"] == "") { die ("You did not enter a username");
if ($_POST["password"] == "") { die ("You did not enter a password");};
if ($_POST["password"] != $_POST["password_confirm"]) { die ("Your passwords don't match"); };
if ($conf == "yes"){if ($_POST["email"] == "") {die ("Site Admin is requested that you supply a valid email address. Please go back and try again");}}
if ($_POST["age"] == "") { die ("You did not enter an age");};
if ($_POST["phone"] == "") { die ("You did not enter a phone number"); };
if ($_POST["area"] == "") { die ("You did not enter an area");};

//lowercase
$usernamel = strtolower($_POST[username]);
$usernamel = str_replace(' ','/space/',$usernamel);

/// check whether usrname exists
$extresult = mysql_query("SELECT * FROM members");
while($row = mysql_fetch_array($extresult))
  {
  if ($row[username] == $usernamel){die ('The username is already inuse. Please go back and try again<br /><br /><a href="create.html">Try Again</a>');};
  };

/// encode psswrd
$passenc = $_POST[password];
$passencon = base64_encode($passenc);

/// insert data under conditions
if ($conf == "yes"){$active = "0";} else { $active = "1"; };
$store = "INSERT INTO `members` (`id`, `username`, `password`, `active`, `age`, `phone`, `area`) VALUES ('', '" . mysql_real_escape_string($usernamel) . "', '" . $passencon . "', '" . $active . "')";
mysql_query($store, $con);

/// confirmation
$to = $_POST[email];
$subject = "Members Account";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: " . $sendmail;

$body = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Tahoma>Thank you for signing up to the members area at ' . $_SERVER['HTTP_HOST'] . '
<BR><BR>Click to activate your account: </FONT><A
href="http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?usrc=' . $_POST[username] . '&activec=true"><FONT face=Tahoma>http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '</FONT></A>
</DIV></BODY></HTML>';

if ($conf == "yes") {
mail($to, $subject, $body, $headers);
echo ("Thank you " . str_replace('/space/',' ',$usernamel) . " your account has been created. Please activate it using the email that has been sent to your address");
} else { echo ('Your account has been created and is also active. You may login now.<br /><br /><a href="index.html">Login Now!</a>');
}
}

?>
</body>
</html>
[/code]
Should work fine.
In this mysql query:
[code]<?php
$store = "INSERT INTO `members` (`id`, `username`, `password`, `active`, `age`, `phone`, `area`) VALUES ('', '" . mysql_real_escape_string($usernamel) . "', '" . $passencon . "', '" . $active . "')";
mysql_query($store, $con);
?>[/code]
You are specifying 7 fields, but only supplying 4 values. This will cause a mysql error, but since you're not checking, your script just dies.
Add an "or die" clause to the mysql_query line:
[code]<?php
$store = "INSERT INTO `members` (`id`, `username`, `password`, `active`, `age`, `phone`, `area`) VALUES ('', '" . mysql_real_escape_string($usernamel) . "', '" . $passencon . "', '" . $active . "')";
mysql_query($store, $con) or die("There is a problem with the query: $store<br>" . mysql_error());
?>[/code]

Ken
Ok ill start again... here is the original code that worked. (bottom)

Now what I have done in create.html is add 3 more fields, age, phone number and area. I want this script to be able to insert them on my database also.

I have edited my database to suit this and the field names are, age, phone, and area.

Please help.

[code]<html>
<head>
<style type="text/css">
<!--
body {
font-family: Tahoma, Arial, sans-serif;
font-size: 12px;
font-weight: bold;
}
-->
</style>
<title>Account Creation System</title></head>
<body>

<?php
/// install file check
if (!file_exists("install.txt")){ die("Admin - Please run install first");};

/// import config
require("config.php");

/// connect to database
$con=mysql_connect($mysql_hst,$mysql_us,$mysql_ps);
if (!$con)
  {
  die('Could not connect: ' . mysql_error() . '<br /><br />Check your config file or contact your server support team.');
  };
 
/// select DB
if (!mysql_select_db($mysql_db, $con)){die ("Could not connect to the database you specified. Make sure it exists and is correctly named within config.php");};

/// active or create?
if ($_GET["activec"] == "true"){
$setact = "UPDATE members SET active = '1' WHERE username = '" . str_replace(' ','/space/',mysql_real_escape_string($_GET["usrc"])) . "'";
mysql_query($setact, $con);
die ('Account activated<br /><br /><a href="index.html">Login Now!</a>');
};


///Thing goes here



/// check filled
if ($_POST["username"] == "") { die ("You did not enter a username"); };
if ($_POST["password"] == "") { die ("You did not enter a password"); };
if ($_POST["password"] != $_POST["password_confirm"]) { die ("Your passwords don't match"); };
if ($conf == "yes"){if ($_POST["email"] == "") {die ("Site Admin is requested that you supply a valid email address. Please go back and try again");};};

//lowercase
$usernamel = strtolower($_POST[username]);
$usernamel = str_replace(' ','/space/',$usernamel);

/// check whether usrname exists
$extresult = mysql_query("SELECT * FROM members");
while($row = mysql_fetch_array($extresult))
  {
  if ($row[username] == $usernamel){die ('The username is already inuse. Please go back and try again<br /><br /><a href="create.html">Try Again</a>');};
  };

/// encode psswrd
$passenc = $_POST[password];
$passencon = base64_encode($passenc);

/// insert data under conditions
if ($conf == "yes"){$active = "0";} else { $active = "1"; };
$store = "INSERT INTO `members` (`id`, `username`, `password`, `active`) VALUES ('', '" . mysql_real_escape_string($usernamel) . "', '" . $passencon . "', '" . $active . "')";
mysql_query($store, $con);

/// confirmation
$to = $_POST[email];
$subject = "Members Account";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: " . $sendmail;

$body = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Tahoma>Thank you for signing up to the members area at ' . $_SERVER['HTTP_HOST'] . '
<BR><BR>Click to activate your account: </FONT><A
href="http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?usrc=' . $_POST[username] . '&activec=true"><FONT face=Tahoma>http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '</FONT></A>
</DIV></BODY></HTML>';

if ($conf == "yes") {
mail($to, $subject, $body, $headers);
echo ("Thank you " . str_replace('/space/',' ',$usernamel) . " your account has been created. Please activate it using the email that has been sent to your address");
} else { echo ('Your account has been created and is also active. You may login now.<br /><br /><a href="index.html">Login Now!</a>');};

?>
</body></html>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.