Web Hosting Vodahost    

Home Take The Royal Tour! Order Now Features Prices
Go Back   Web Hosting > BlueVoda Website Builder Forums > Forms

Notices

Forms Discussion and help related to designing and implementing forms in the BlueVoda Website Builder.

Reply
 
LinkBack Thread Tools
  #1  
Old 07-24-2006, 09:32 PM
Staff Sergeant
 
Join Date: Jun 2006
Posts: 43
Default PHP & mysql

I am working on a registration and login form for my website and have reached the point where I can submit the data, insert it into the database, and validate it. I can't seem to get the users to the proper pages after the information has been checked. I have tried the "header" statement to no avail. I am using "if---else" to validate. Here is my script for validation:

<html>
<body>
<?php
$con = mysql_connect("localhost","colescom_colen","****** *");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("colescom_names", $con);
$result = mysql_query("SELECT * FROM person
WHERE name='Colen'");
while($row = mysql_fetch_array($result))
$name=$row['name'];
$email=$row['email'];
if ($name=="Colen")
header("Location: ThankYou.html");
else
header("Location: NoRecord.html");
echo "<br />";
?>
</body>
<html>

When I run the script, I get this error:

Warning: Cannot modify header information - headers already sent by (output started at /home/colescom/public_html/where.php:3) in /home/colescom/public_html/where.php on line 16

I have used "echo" statements in place of the "header" statements to let me know whether the information in the database matches. That works. Any help would be greatly appreciated.

Anyone who wishes to study php or mysql should check out this website:

http://www.w3schools.com/php/php_intro.asp
__________________
No matter how fast you are going, there is always someone trying to pass.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old 07-24-2006, 11:12 PM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 9,342
Default Re: PHP & mysql

Try:

<html>
<body>
<?php
$con = mysql_connect("localhost","colescom_colen","****** *");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("colescom_names", $con);
$result = mysql_query("SELECT * FROM person
WHERE name='Colen'");
while($row = mysql_fetch_array($result))
$name=$row['name'];
$email=$row['email'];
if ($name=="Colen")
{
header("Location: ThankYou.html");
}
else
{
header("Location: NoRecord.html");
}
echo "<br />";
?>
</body>
<html>


But why is it all included in the html tags ?
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old 07-25-2006, 03:43 AM
Staff Sergeant
 
Join Date: Jun 2006
Posts: 43
Default Re: PHP & mysql

I have been going thru the tutorials at: http://www.w3schools.com/php/php_variables.asp

Some of the examples include the html tags and some do not. Apparently it makes no difference whether they are there or not as far as the php code is concerned as long as the necessary php start and stop tags are in place
__________________
No matter how fast you are going, there is always someone trying to pass.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old 07-25-2006, 03:53 AM
Staff Sergeant
 
Join Date: Jun 2006
Posts: 43
Default Re: PHP & mysql

Here is a script I have as login.php:

<?php
$name=$_POST["name"];
$email=$_POST["email"];
$con = mysql_connect("localhost","colescom_colen","****** **");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("colescom_colen", $con);
$result = mysql_query("SELECT * FROM person)
WHERE email=$email);
if $result==$email;
{
echo 'Login okay';
else
echo 'Not in system';
}
mysql_close($con);
?>

I also have a login.html which transmits a login email address. When I submit the address I get the following error:

Parse error: syntax error, unexpected $end in /home/colescom/public_html/login.php on line 20


There is no line 20 in my script. I did a search on this type of error but could not find an answer.
__________________
No matter how fast you are going, there is always someone trying to pass.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old 07-25-2006, 08:44 AM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 9,342
Default Re: PHP & mysql

1. Did you get any results by inserting the {
and } ?
2. The html tags are used if in the same page you have to combine php with some html code. If the script is stand alone, as it seems to be in your case (the presense of two " headr: .... " lines makes me think so) there is no need for html tags.
3. I think that you have a small error in here, and this caused your script to go directly to the end, which causes the error message.

Try it like this: (please note that i have not tested it)


<?php
$name=$_POST["name"];
$email=$_POST["email"];
$con = mysql_connect("localhost","colescom_colen","****** **");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("colescom_colen", $con);
$result = mysql_query("SELECT * FROM person WHERE email=$email");
while ( $row = mysql_fetch_array($result))
{
if ($row['email'] = $email)
{
$registered = "True";
}
}
mysql_close($con);
if ($registered !="")
{
echo 'Login okay';
header("Location: page_to_send_him_to.html"); // Use this line if you wish to send him to a specific page
}
else
{
echo 'You are not registered yet.';
header("Location: registrationpage.html"); // Use this line if you wish to send him to the registration form page
}
?>
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old 07-25-2006, 03:56 PM
Staff Sergeant
 
Join Date: Jun 2006
Posts: 43
Default Re: PHP & mysql

Here is the script as I tried it:

<?php
$name=$_POST["name"];
$email=$_POST["email"];
$con = mysql_connect("localhost","colescom_colen","****** ");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("colescom_colen", $con);
$result = mysql_query("SELECT * FROM person WHERE email=$email");
while ( $row = mysql_fetch_array($result))
{
if ($row['email'] = $email)
$registered = "True"
mysql_close($con);
}
if ($registered !="")
{
echo 'Login okay';
header("Location: ThankYou.html"); // Use this line if you wish to send him to a specific page
}
else
{
echo 'You are not registered yet.';
header("Location: NoRecord.html"); // Use this line if you wish to send him to the registration
form page
}
?>

I get this error:

Parse error: syntax error, unexpected T_STRING in /home/colescom/public_html/login.php on line 15

Line 15: mysql_close($con);

I checked it with ***ad (a php editor). All parentheses and brackets are in place.

I noticed you closed the connection to the database before using the header statement. Is this necessary to get the header statement to work?
__________________
No matter how fast you are going, there is always someone trying to pass.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old 07-25-2006, 04:09 PM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 9,342
Default Re: PHP & mysql

You have moved one of the curly brackets - the one before the mysql_close($con);

I also made a couple of changes. Please copy / paste and try again.

The connection is only needed till the check is done. As a good rule, the connection should be closed after every querry, unless you use loop in loop techniques which are rather complicated.
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old 07-25-2006, 04:28 PM
Staff Sergeant
 
Join Date: Jun 2006
Posts: 43
Default Re: PHP & mysql

What were the other changes you made?
__________________
No matter how fast you are going, there is always someone trying to pass.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old 07-25-2006, 09:42 PM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 9,342
Default Re: PHP & mysql

Put two curly bracket where missing.
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 04:26 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC7
2005-2009 VodaHost Web Hosting Your Perfect Web Host - All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176