Jump to content

Getting a blank page


affordit

Recommended Posts

Hello all

Using the script below

I enter no username it tells me username is required thats right.

Then I enter a known username and I get username already exists that right.

Then I enter a new username and submit again and I get a blank page ???

Anyone know what im doing wrong?

 

<?php
// MAKE SURE USERNAME IS ENTERED
$username=$_POST['username']; 
if (empty($username))
{
echo"<a href='add_advertiser.php'>Username is required</a>";
exit(); // stop exec here  
}
// IF USERNAME IS ENTERED VERIFY IT IS NOT ALREADY IN THE DB
$username=$_POST['username']; 
if (!empty($username)) 
{ 
include("sharons_dbinfo.inc.php");
mysql_connect(mysql,$name,$password);
mysql_select_db($database) or die( "Unable to database"); 

$query = "Select username from  login Where username = '$username'";
$result=mysql_query($query) or die (mysql_error());
if (mysql_num_rows($result)>0)
print "That Username is already in use";
exit();
}
// INSURE ALL OTHER FIELDS ARE ENTERED

$address=$_POST['address']; 
if (empty($address)) 
{
echo"<a href='add_advertiser.php'>Address is required</a>"; 
exit(); // stop exec here 
} 

$city=$_POST['city']; 
if (empty($city)) 
{ 
echo"<a href='add_advertiser.php'>City is required.</a>"; 
exit(); // stop exec here 
} 

$state=$_POST['state']; 
if (empty($state)) 
{ 
echo"<a href='add_advertiser.php'>All fields are required EXCEPT company.</a>"; 
exit(); // stop exec here 
} 

$zip=$_POST['zip']; 
if (empty($zip)) 
{ 
echo"<a href='add_advertiser.php'>All fields are required EXCEPT company.</a>"; 
exit(); // stop exec here 
}

$phone=$_POST['phone']; 
if (empty($phone)) 
{ 
echo"<a href='add_advertiser.php'>All fields are required EXCEPT company.</a>"; 
exit(); // stop exec here 
} 

$email=$_POST['email']; 
if (empty($email)) 
{ 
echo"<a href='add_advertiser.php'>All fields are required EXCEPT company.</a>"; 
exit(); // stop exec here 
} 
// EVERYTHING FROM HERE DOWN WORKS FINE

 

Thanks

Link to comment
Share on other sites

Im not displaying anything i am sending an email and inserting into 2 tables everything worked well until I added the section at the top that checks to see if the username already exists.

 

Here is the whole page that the values come from

<?php
session_start(); // start up your PHP session!
include("client_info3.php"); 
include("top_mid_nav.inc"); 
print"
<html><body>
<br><br>";

if( isset($username) ){
print "<h3>You are already registered.</h3>
To change your username or password go <a href='change_details.php?username=$username&psword=$psword'>Here</a>";
	print "<br><b>See how it works $username, if you log out the registration page will be visible.<br><br>Also if you are logged out you can not get to the Ad Products page</b>";
}
else{
print "
<center><font size='+2'>Registration</font></center><br>
<form action=submit_registration.php method='POST'>
<table align='center'>
<tr>
<td width='125'><img src='b_tipp.png' alt='If you do not have a business you can leave this field blank'>Company Name:</td><td><input type=text name=company size=30 maxlength=100></td>
</tr>
<tr>
<td><img src='b_tipp.png' alt='This will be your username and will be cAsE SeNsItIvE'>Your Name:</td><td><input type=text name=username size=30 maxlength=100></td>
</tr>
<tr>
<td><img src='16x16spacer.gif'>Address:</td><td><input type=text name=address size=30 maxlength=100></td>
</tr>
<tr>
<td><img src='16x16spacer.gif'>City:</td><td><input type=text name=city size=30 maxlength=100></td>
</tr>
<tr>
<td><img src='16x16spacer.gif'>State:</td><td><input type=text name=state size=2 maxlength=2></td>
</tr>
<tr>
<td><img src='16x16spacer.gif'>Zip:</td><td><input type=text name=zip size=5 maxlength=100></td>
</tr>
<tr>
<td><img src='16x16spacer.gif'>Phone:</td><td><input type=text name=phone size=30 maxlength=100></td>
</tr>
<tr>
<td><img src='b_tipp.png' alt='You must enter a valid email address so your new password can be emailed to you'>Email:</td><td><input type=text name=email size=30 maxlength=100></td>
</tr>
<tr>
<td><img src='b_tipp.png' alt='Write a question only you know the answer to. It will be used if you lose your password.'>Verification Question:</td><td><input type=text name=lost_password size=30 maxlength=100></td>
</tr>
<tr>
<td><img src='b_tipp.png' alt='Write your answer to the above question.'>Verification Answer:</td><td><input type=text name=lost_password_answer size=30 maxlength=100></td>
</tr>
<tr>
<td align='center' colspan='2'><br><input type=submit name='Submit' value='Register Now'></td>
</tr>
</table>
</form>
</body>
</html>";
}
?>

 

And here is the page that processes the values

// MAKE SURE USERNAME IS ENTERED
$username=$_POST['username']; 
if (empty($username))
{
echo"<a href='add_advertiser.php'>Username is required</a>";
exit(); // stop exec here  
}
// IF USERNAME IS ENTERED VERIFY IT IS NOT ALREADY IN THE DB
$username=$_POST['username']; 
if (!empty($username)) 
{ 
include("sharons_dbinfo.inc.php");
mysql_connect(mysql,$name,$password);
mysql_select_db($database) or die( "Unable to database"); 

$query = "Select username from  login Where username = '$username'";
$result=mysql_query($query) or die (mysql_error());
if (mysql_num_rows($result)>0)
print "That Username is already in use";
exit();
}
// INSURE ALL OTHER FIELDS ARE ENTERED

$address=$_POST['address']; 
if (empty($address)) 
{
echo"<a href='add_advertiser.php'>Address is required</a>"; 
exit(); // stop exec here 
} 

$city=$_POST['city']; 
if (empty($city)) 
{ 
echo"<a href='add_advertiser.php'>City is required.</a>"; 
exit(); // stop exec here 
} 

$state=$_POST['state']; 
if (empty($state)) 
{ 
echo"<a href='add_advertiser.php'>All fields are required EXCEPT company.</a>"; 
exit(); // stop exec here 
} 

$zip=$_POST['zip']; 
if (empty($zip)) 
{ 
echo"<a href='add_advertiser.php'>All fields are required EXCEPT company.</a>"; 
exit(); // stop exec here 
}

$phone=$_POST['phone']; 
if (empty($phone)) 
{ 
echo"<a href='add_advertiser.php'>All fields are required EXCEPT company.</a>"; 
exit(); // stop exec here 
} 

$email=$_POST['email']; 
if (empty($email)) 
{ 
echo"<a href='add_advertiser.php'>All fields are required EXCEPT company.</a>"; 
exit(); // stop exec here 
} 

// From here it sends mail and inserts to 2 tables

Link to comment
Share on other sites

I enter no username it tells me username is required thats right.

Then I enter a known username and I get username already exists that right.

Then I enter a new username and submit again with no address and I get a blank page it should be telling me that the address is required when I remove all of that part of the page that I posted and hit submit with nothing entered in any of the fields except email address it inserts a blank record and sens the mail.

Link to comment
Share on other sites

Try something like this then to check if variables are empty:

 

<?php

if(!empty($var1) && !empty($var2) && !empty($var3)) {

//run code here

}

else { 
echo "Please check that are fields are filled out properly<br>
<input type='text' name='var1' value='$value1'><br>
<input type='text' name='var2' value='$var2'><br>";
}


?>

Link to comment
Share on other sites

I got it I had change this

// MAKE SURE USERNAME IS ENTERED
$username=$_POST['username']; 
if (empty($username))
{
echo"<a href='add_advertiser.php'>Username is required</a>";
exit(); // stop exec here  
}
// IF USERNAME IS ENTERED VERIFY IT IS NOT ALREADY IN THE DB
$username=$_POST['username']; 
if (!empty($username)) 
{ 
include("sharons_dbinfo.inc.php");
mysql_connect(mysql,$name,$password);
mysql_select_db($database) or die( "Unable to database"); 

$query = "Select username from  login Where username = '$username'";
$result=mysql_query($query) or die (mysql_error());
if (mysql_num_rows($result)>0)
print "That Username is already in use";
exit();

 

To this

// MAKE SURE USERNAME IS ENTERED
$username=$_POST['username']; 
if (empty($username))
{
echo"<a href='add_advertiser.php'>Username is required</a>";
exit(); // stop exec here  
}
// IF USERNAME IS ENTERED VERIFY IT IS NOT ALREADY IN THE DB
$username=$_POST['username']; 
if (!empty($username)) 
{ 
include("sharons_dbinfo.inc.php");
mysql_connect(mysql,$name,$password);
mysql_select_db($database) or die( "Unable to database"); 

$query = "Select username from  login Where username = '$username'";
$result=mysql_query($query) or die (mysql_error());
if (mysql_num_rows($result)>0){
print "That Username is already in use";
exit();
}
   }

 

Thank Guys

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.