Jump to content

[SOLVED] please can anyone see what is wrong with this


Recommended Posts

i have been looking at this code for about an hour, when i load it up nothing shows up on the screen. i am sure it is simple but as you know he longer you look the hard it gets to spot the error..

 

<?php //reg.php

//address error handling
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

//set the page title 
ini_set ('TITLE', 'register');

//basic html formatting 
print '<div id="leftcontent">
<h1>Registration Form</h1>
<p>Register so that you can take advantage of this, that and other things.</p>';

//check if the form has been submitted
if (isset ($_POST['submit'])) {

$problem = FALSE; // no problems so far

//check each value 
if (empty ($_POST['username')) {
	$problem = TRUE;
	print '<p>Please enter your username</p>';
}

if(empty ($_POST['first_name'])) {
	$problem = TRUE;
	print '<p>Plase enter your First Name</P>';
}

if (empty ($_POST['last_name'])) {
	$problem = TRUE;
	print '<p>Please enter your Last Name</p>';
}

if (empty ($_POST['email'])) {
	$problem = TRUE;
	print '<p>Please enter your email</p>';
}

if (empty($_POST['password1'])) {
	$problem = TRUE;
	print '<p>Please enter your Password</p>';
}

if ($_POST['password1'] != $_POST['password2']){
	$problem = TRUE;
	print '<p>Your password did not match your confirmed password!</p>';
}

if (!$problem) { // if there weren't any probles...

	print '<p>You are now registered!<br />Okey, you are not really registerd but...</p>';

}else { // forgoten field.

	print '<p>Please try again!</p>';

}
}//end of handle for if 


//Display the form 
print '<form action="register.php" method="post"><p>';
print 'Username:<input type="text" name="username" size="20" value="' . $_POST['username'] . '"/><br />'; 
print 'First Name: <input type="text" name="first_name" size="20" value="' . $_POST['first_name'] . '"/><br />';
print 'Last Name: <input type="text" name="last_name" size="20" value="' . $_POST['last_name'] . '"/><br />';
print 'Email Address: <input type="text" name="email" size="20" value="' . $_POST['email'] . '"/><br />';
print 'Password: <input type="password" name="password1" size="20" /><br />';
print 'Confirm Password: <input type="password" name="password2" size="20" /><br />';
<input value="submit" name="submit" value="Register!" /></p>
</form>

//complete the html formatting stuff.
print '</div>';

include ('templates/footer.php'); // need the footer
?>

This is incorrect....

 

//set the page title 
ini_set ('TITLE', 'register');

 

Im not sure what your trying to do, but ini_set is made for setting php configuration options. Maybe you meant...

 

define('TITLE','register');

 

which defines a constant. Other than that, the only thing I can see is a few print statements missing. ie;

 

<input value="submit" name="submit" value="Register!" /></p>
</form>

 

should be...

 

print '<input value="submit" name="submit" value="Register!" /></p>';
print '</form>'

ok this problem must be with my apache server as you say nothing is wrong with it but on mine nothing happens

 

so is there any idea on what it could be and what i could do with it

 

thanks

 

WHAT!!!!

 

 

read thorpe's post

 

This is incorrect....

 

//set the page title 
ini_set ('TITLE', 'register');

 

Im not sure what your trying to do, but ini_set is made for setting php configuration options. Maybe you meant...

 

define('TITLE','register');

 

which defines a constant. Other than that, the only thing I can see is a few print statements missing. ie;

 

<input value="submit" name="submit" value="Register!" /></p>
</form>

 

should be...

 

print '<input value="submit" name="submit" value="Register!" /></p>';
print '</form>'

this works fine (except for the lack of footer.php)

 

 

fixed a few more errors

 

<?php //reg.php

//address error handling
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

//set the page title 
define ('TITLE', 'register');

//basic html formatting 
print '<div id="leftcontent">
<h1>Registration Form</h1>
<p>Register so that you can take advantage of this, that and other things.</p>';

//check if the form has been submitted
if (isset ($_POST['submit'])) {

$problem = FALSE; // no problems so far

//check each value 
if (empty ($_POST['username'])) {
	$problem = TRUE;
	print '<p>Please enter your username</p>';
}

if(empty ($_POST['first_name'])) {
	$problem = TRUE;
	print '<p>Plase enter your First Name</P>';
}

if (empty ($_POST['last_name'])) {
	$problem = TRUE;
	print '<p>Please enter your Last Name</p>';
}

if (empty ($_POST['email'])) {
	$problem = TRUE;
	print '<p>Please enter your email</p>';
}

if (empty($_POST['password1'])) {
	$problem = TRUE;
	print '<p>Please enter your Password</p>';
}

if ($_POST['password1'] != $_POST['password2']){
	$problem = TRUE;
	print '<p>Your password did not match your confirmed password!</p>';
}

if (!$problem) { // if there weren't any probles...

	print '<p>You are now registered!<br />Okey, you are not really registerd but...</p>';

}else { // forgoten field.

	print '<p>Please try again!</p>';

}
}//end of handle for if 


//Display the form 
print '<form action="register.php" method="post"><p>';
print 'Username:<input type="text" name="username" size="20" value="' . $_POST['username'] . '"/><br />'; 
print 'First Name: <input type="text" name="first_name" size="20" value="' . $_POST['first_name'] . '"/><br />';
print 'Last Name: <input type="text" name="last_name" size="20" value="' . $_POST['last_name'] . '"/><br />';
print 'Email Address: <input type="text" name="email" size="20" value="' . $_POST['email'] . '"/><br />';
print 'Password: <input type="password" name="password1" size="20" /><br />';
print 'Confirm Password: <input type="password" name="password2" size="20" /><br />';
print '<input type="submit" value="submit" name="submit" value="Register!" /></p>';
print '</form>';

//complete the html formatting stuff.
print '</div>';

include ('templates/footer.php'); // need the footer

?>

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.