•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 429,966 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,602 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 4711 | Replies: 4
![]() |
[php]<?
$DBhost = "localhost";//location of mySQL on server/site
$DBuser = "michael";//User name for logging onto mySQL
$DBpass = "";//Password for logging onto mySQL
$DBName = "user_login_info";//Name of the databse for logging into
$table = "login_info";//Name of the Table to be used steps to create are included
$name = "$_POST[name]";//Name that the person gave on the form
$email = "$_POST[email]";//Email that person gave on the form
$con_email = "$_POST[confirm_email]";//confirm their email is correct
$sex = "$_POST[sex]";//sex of the person
$month = "$_POST[month]";//month person was born
$day = "$_POST[day]";//day person was born
$year = "$_POST[year]";//year person was born
if ($email != $con_email)
{
echo "sorry the emails you provided do not match!<br />";
echo "Please use the back button to correct this error and resubmit<br />";
}
else
{
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); //connecting to the database using the variable set
@mysql_select_db("$DBName") or die("Unable to select database $DBName"); //at connection to the databse select DBNAME (phpforms) or tell that it couldnt connect
$sqlquery = "INSERT INTO $table VALUES('$id','$name','$email','$email','$con_email','$sex','$month','$day','$year')"; //Telling the mySQL to insert the values from the form into the databse coresponding with the form
$results = mysql_query($sqlquery); //Query the results
mysql_close();
echo "
<html>
<head>
<title> Registerd Data </title>
</head>
<body>
<center>
<table border='0' width='500'>
<tr>";
echo " <td>
<font face='verdana' size='+0'>
<center>
<p>You Just Entered This Information Into the Database</p>
</center>";
//display the information that user submitted in the previous form
echo " <blockquote>
<center>
<p>
Name : $name
</p>
<p>
E-Mail : $email
</p>
<p>
Sex : $sex
</p>
<p>
Birthdate: $month / $day / $year
</p>
</center>
</blockquote>
</td>
</tr>
</table>
</center>
</body>
</html>";
}
?>[/php]
for some reason i cant get this to submit any data into to my database, ive been trying to create a sort of registration form, so i modified the tutorial that i had been working on, but now it wont send the data to my database, but it will display the information that i have entered at the bottom of the screen (the info is displayed in the 'echo' areas.
heres the code for the form if you need to see that too
$DBhost = "localhost";//location of mySQL on server/site
$DBuser = "michael";//User name for logging onto mySQL
$DBpass = "";//Password for logging onto mySQL
$DBName = "user_login_info";//Name of the databse for logging into
$table = "login_info";//Name of the Table to be used steps to create are included
$name = "$_POST[name]";//Name that the person gave on the form
$email = "$_POST[email]";//Email that person gave on the form
$con_email = "$_POST[confirm_email]";//confirm their email is correct
$sex = "$_POST[sex]";//sex of the person
$month = "$_POST[month]";//month person was born
$day = "$_POST[day]";//day person was born
$year = "$_POST[year]";//year person was born
if ($email != $con_email)
{
echo "sorry the emails you provided do not match!<br />";
echo "Please use the back button to correct this error and resubmit<br />";
}
else
{
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database"); //connecting to the database using the variable set
@mysql_select_db("$DBName") or die("Unable to select database $DBName"); //at connection to the databse select DBNAME (phpforms) or tell that it couldnt connect
$sqlquery = "INSERT INTO $table VALUES('$id','$name','$email','$email','$con_email','$sex','$month','$day','$year')"; //Telling the mySQL to insert the values from the form into the databse coresponding with the form
$results = mysql_query($sqlquery); //Query the results
mysql_close();
echo "
<html>
<head>
<title> Registerd Data </title>
</head>
<body>
<center>
<table border='0' width='500'>
<tr>";
echo " <td>
<font face='verdana' size='+0'>
<center>
<p>You Just Entered This Information Into the Database</p>
</center>";
//display the information that user submitted in the previous form
echo " <blockquote>
<center>
<p>
Name : $name
</p>
<p>
E-Mail : $email
</p>
<p>
Sex : $sex
</p>
<p>
Birthdate: $month / $day / $year
</p>
</center>
</blockquote>
</td>
</tr>
</table>
</center>
</body>
</html>";
}
?>[/php]
for some reason i cant get this to submit any data into to my database, ive been trying to create a sort of registration form, so i modified the tutorial that i had been working on, but now it wont send the data to my database, but it will display the information that i have entered at the bottom of the screen (the info is displayed in the 'echo' areas.
heres the code for the form if you need to see that too
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Handling forms with PHP</title> </head> <body> <center> <form method="post" action="confirm_reg.php"> <table border="1"> <tr> <td colspan="2"> Please Register to continue! </td> </tr> <tr> <td> </td> </tr> <tr> <td align="left"> <p><b> Your Name:</b> <input type="text" name="name" id="name"></p> <p><b> E-Mail Address:</b> <input type="text" name="email" id="email"></p> <p><b> E-Mail Again:</b> <input type="text" name="confirm_email" id="confirm_email"></p> <p><b> Sex:</b> <select name="sex" id="sex"> <option value="unknown"> Unknown </option> <option value="male"> Male </option> <option value="female"> Female </option> </select></p> <p><b> Birthdate:</b> <input type="text" size="2" maxlength="2" name="month" id="month">/ <input type="text" size="2" maxlength="2" name="day" id="day">/ <input type="text" size="4" maxlength="4" name="year" id="year"></p> </td> </tr> <tr> <td colspan="2"> <input type="submit" value="Tell us!"> </td> </tr> </table> </form> </center> </body> </html>
!!!!! WARNING YOUR COMPUTER MAY BE INFECTED WITH SPYWARE!!!! PAY AN OVER PRICED AMMOUNT TO HAVE SOMTHING FIXED WE PLACED THERE IN THE FIRST PLACE!!!!!!!!!
sound familiar, know how to block yourself and keep yourself clean.
_____________________
http://www.lavasoftusa.com/ -->adaware
http://www.safer-networking.org/en/index.html -->spybot S&D
http://www.javacoolsoftware.com/spywareblaster.html -->spywareblaster
http://www.javacoolsoftware.com/spywareguard.html -->spywareguard
_____________________
and dont forget to spread the reputation to those that deserve!
sound familiar, know how to block yourself and keep yourself clean.
_____________________
http://www.lavasoftusa.com/ -->adaware
http://www.safer-networking.org/en/index.html -->spybot S&D
http://www.javacoolsoftware.com/spywareblaster.html -->spywareblaster
http://www.javacoolsoftware.com/spywareguard.html -->spywareguard
_____________________
and dont forget to spread the reputation to those that deserve!
•
•
Join Date: Jun 2004
Location: Phoenix Arizona
Posts: 115
Reputation:
Rep Power: 5
Solved Threads: 2
$results = mysql_query($sqlquer y); //Query the results
if(!$results){
echo(mysql_error());
}
if(!$results){
echo(mysql_error());
}
Need a website designer? arizona web design : phoenix web design : MCP Media intelligent web design and web development solutions. MCP Media is owned and operated by Chris Hooley - who happens to be a real nerd... on purpose :-)
•
•
•
•
Originally Posted by Arizona Web
$results = mysql_query($sqlquer y); //Query the results
if(!$results){
echo(mysql_error());
}
here are the results.
Column count doesn't match value count at row 1
(heres a screenshot of what the database looks like)
•
•
•
•
Originally Posted by Killer_Typo
thank you thank you thank you.
here are the results.
Column count doesn't match value count at row 1
(heres a screenshot of what the database looks like)
Last edited by samaru : Jun 15th, 2004 at 12:57 am.
!!!!! WARNING YOUR COMPUTER MAY BE INFECTED WITH SPYWARE!!!! PAY AN OVER PRICED AMMOUNT TO HAVE SOMTHING FIXED WE PLACED THERE IN THE FIRST PLACE!!!!!!!!!
sound familiar, know how to block yourself and keep yourself clean.
_____________________
http://www.lavasoftusa.com/ -->adaware
http://www.safer-networking.org/en/index.html -->spybot S&D
http://www.javacoolsoftware.com/spywareblaster.html -->spywareblaster
http://www.javacoolsoftware.com/spywareguard.html -->spywareguard
_____________________
and dont forget to spread the reputation to those that deserve!
sound familiar, know how to block yourself and keep yourself clean.
_____________________
http://www.lavasoftusa.com/ -->adaware
http://www.safer-networking.org/en/index.html -->spybot S&D
http://www.javacoolsoftware.com/spywareblaster.html -->spywareblaster
http://www.javacoolsoftware.com/spywareguard.html -->spywareguard
_____________________
and dont forget to spread the reputation to those that deserve!
•
•
Join Date: Jun 2004
Location: Phoenix Arizona
Posts: 115
Reputation:
Rep Power: 5
Solved Threads: 2
NP bud. While I am developing I always echo errors after every SQL statement in PHP and keep debug on in other languages. Makes it easier to know off the bat where the problems are.
Need a website designer? arizona web design : phoenix web design : MCP Media intelligent web design and web development solutions. MCP Media is owned and operated by Chris Hooley - who happens to be a real nerd... on purpose :-)
•
•
Join Date: Feb 2002
Location: Long Island, NY
Posts: 1,134
Reputation:
Rep Power: 12
Solved Threads: 5
•
•
•
•
Originally Posted by Killer_Typo
srry for the double post, but i figured it out, i had accidently included $email twice, once removing the second $email it all worked out. thanks arizona web for the help, i wouldnt have thought to double check that if i hadnt seen the error that i got.
_.:: my websites ::._
blog @ www.samaru.net * engi No Jutsu @ www.narutorp.net * portfolio @ shinylight.com
deviantART: inscissor
blog @ www.samaru.net * engi No Jutsu @ www.narutorp.net * portfolio @ shinylight.com
deviantART: inscissor
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access avatar backup blog breach broadband code combo competition crime daniweb data data protection data transfer database design drive dropdownlist forensics gentoo government hacker hard hardware hitachi ibm internet linux medicine module net news normalization php reuse security server spam sql storage survey terabyte web wikipedia
- Porblem in UTF-8 support on CSV/EXCEL (PHP)
- writitng data from php to mysql (PHP)
- dreamweaver, PHP and submit form query (PHP)
- mySQL database searching for registration (MySQL)
Other Threads in the PHP Forum
- Previous Thread: PHP Sessions on IIS
- Next Thread: phpbb2.X news?



Linear Mode