I am transferring my website from a diff host and cant get my any of my forms to work.I have spent over 2 days trying to get a single GD shred of information into my database here at x10hosting can not figure out why it just wont work. Tried different approaches and could really use a fresh pair of eyes here thanx in advance.
Here is a live example of the error code. http://muscle.pcriot.com/test.php
php codebox 1 (my form) php codebox 2 (driver for the form).
Just incase your lazy and did not go to the page i noted previously as my error code. This is the error i am receiving
Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in /home/meanbot/public_html/logincreate.php on line 10
for lines 11,12,13,14 too.
Here is a live example of the error code. http://muscle.pcriot.com/test.php
php codebox 1 (my form) php codebox 2 (driver for the form).
PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META content="text/html; charset=unicode" http-equiv=Content-Type>
<META name=description content="">
<META name=keywords content="">
<META name=GENERATOR content="MSHTML 8.00.6001.22967"></HEAD>
<BODY>
<P>
<TABLE cellPadding=1 width=201 background=backer.jpg height=186>
<TBODY>
<TR>
<TD align=left>
<FORM method="post" name="signup" action="logincreate.php">
<CENTER><B><FONT color=#cccccc>Get started
here.</FONT></B></CENTER><BR>
<LABEL for="firstname"></LABEL> <INPUT id="firstname"
onclick="this.value='';" value="first name...." size="25"
name="firstname"><BR>
<LABEL for="lastname"></LABEL> <INPUT id="lastname"
onclick="this.value='';" value="last name...." size="25"
name="lastname"><BR>
<LABEL for="email"></LABEL> <INPUT
id="email" onclick="this.value='';" value="Email..." size="25" type="email" name="email"> <BR>
<FONT
color=#cccccc><B> Password:</B></FONT><BR><LABEL
for="password1"></LABEL> <INPUT id="password1" onclick="this.value='';" value="Password" size="25" type="password" name="password1"><FONT
color=#cccccc><B> (retype)</B></FONT><BR><LABEL
for="password2"></LABEL> <INPUT id="password2"
onclick="this.value='';" value="Password" size="25" type="password"
name="password2"><BR> <INPUT value="Sign Up" type="submit" name="submit"> </FORM>
</TD>
</TR>
</TBODY>
PHP:
<?php
require_once('connectvars.php');
// Connect to the database
$dbc = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if (isset($_POST['submit'])) {
// Grab the profile data from the POST
$firstname = mysql_real_escape_string($dbc, trim($_POST['firstname']));
$lastname = mysql_real_escape_string($dbc, trim($_POST['lastname']));
$password1 = mysql_real_escape_string($dbc, trim($_POST['password1']));
$password2 = mysql_real_escape_string($dbc, trim($_POST['password2']));
$email = mysql_real_escape_string($dbc, trim($_POST['email']));
function isValidEmail($email){
$pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";
if (eregi($pattern, $email)){
return true;
}
else {
return false;
}
}
if (!empty($firstname) && !empty($lastname) && !empty($password1) && !empty($password2) && !empty($email) && ($password1 == $password2)) {
// Make sure someone isn't already registered using this email
if (isValidEmail($_POST['email'])){
echo " ";
}
else{
echo "The email: ".$_POST['email']." is invalid!";
echo "<a href='javascript:history.back(1);'>Click here to go back and try Again.</A>";
exit();
}
$query = "SELECT * FROM meanbot_ta WHERE email = '$email'";
$data = mysql_query($dbc, $query);
if (mysql_num_rows($data) == 0) {
// The email is unique, so insert the data into the database
$query = "INSERT INTO meanbot_ta (firstname, lastname, email, blah, llogin) VALUES ('$firstname', '$lastname', '$email', SHA('$password1'), NOW())";
mysql_query($dbc, $query);
echo '<p>Your new account has been successfully created. You\'re now ready to <a href="login.php">log in</a>, and setup your ACCOUNT. </p><BR /><BR /><BR />';
echo '<TABLE align="center" width="80%"><TR><TD valign="top" width="60%"><font face="arial" size="5" color="#003399"><B>What is my next step?</font></B><br /> <font face="verdana" size="2" color="#666666">Now that you have a Account. You can make or edit your fitness log. Follow the <a href="login.php">log in</a> link to begin.<br /><br /> <B>*</B>You can allways make changes by loging in from our main page then finding the link in the top left corn labeled "Edit profile".';
echo "</font></td><TD><fieldset><legend><U>Here is your log-in information.</u></legend>";
echo 'The User Name: '.$_POST['email'].'<BR />';
echo "The password: ".$_POST['password1']."<BR />";
echo "The email: ".$_POST['email']."</font><BR /><font face=\"verdana\" size=\"2\" color=\"#666666\">*Your email address.</font></fieldset></TD></TR></TABLE>";
// Confirm success with the user
mysql_close($dbc);
exit();
}
else {
// An account already exists for this email, so display an error message
echo '<p class="error">An account already exists for this Email. Please use a try a different email.</p>';
$email = "";
}
}
else {
echo '<p class="error">You must enter all of the sign-up data, including the desired password twice.</p>';
}
}
mysql_close($dbc);
?>
</body></html>
Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in /home/meanbot/public_html/logincreate.php on line 10
for lines 11,12,13,14 too.