Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PLEASE HELP

Featured Replies

Hi

This is the second time i have posted this script. i still cannot get it working..

 

Please help

 

if (isset($_POST['submit'])) { //handle the forms



//trim all the incoming data:

$trimmed = array_map('trim', $_POST);

//Assume invalid values:
$fn = $ln = $e = $p = $fl = $sl = $t = $c = $pc = $cn = FALSE;

//check for a first name
if (preg_match ('/^[A-Z \'.-]{2,20}$/i',$trimmed['first_name'])) {

$fn = mysqli_real_escape_string ($mysqli, $trimmed['first_name']);
} else {

echo '<p class="error">Please enter your first name!</p>';

}

//check for a last name
if (preg_match ('/^[A-Z\'.-]{2,20}$/i',$trimmed['last_name'])) {

$ln = mysqli_real_escape_string ($mysqli, $trimmed['last_name']);
} else {
echo '<p class="error">Please enter your last name!</p>';

}

//check for an email address:
if (preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $trimmed['email'])) {
		$e = mysqli_real_escape_string ($mysqli, $trimmed['email']);

}else {

//check for a password and match against confirm password
if (preg_match ('/^\w{4.20}$/', $trimmed['password1'])) {
if ($trimmed['password1'] == $trimmed['password2']) {

	$p = mysqli_real_escape_string ($mysqli, $trimmed['password1']);
} else {

	echo ' <p class="error">Your password did not match the confirmed password</p>';
}
} else {
echo '<p class="error">Please enter a valid password!</p>';
}

//check for a first line of address
if (preg_match ('/^[A-Z\'.-]{2,20}$/i',$trimmed['first_line'])) {

$fl = mysqli_real_escape_string ($mysqli, $trimmed['first_line']);
} else {
echo '<p class="error">Please enter the first line of your address!</p>';

}


//check for a second line of address
if (preg_match ('/^[A-Z\'.-]{2,20}$/i',$trimmed['second_line'])) {

$sl = mysqli_real_escape_string ($mysqli, $trimmed['second_line']);
} else {
echo '<p class="error">Please enter the second line of your address!</p>';

}

//check for a town
if (preg_match ('/^[A-Z\'.-]{2,20}$/i',$trimmed['town'])) {

$t = mysqli_real_escape_string ($mysqli, $trimmed['town']);
} else {
echo '<p class="error">Please enter your town!</p>';

}


//check for a city
if (preg_match ('/^[A-Z\'.-]{2,20}$/i',$trimmed['city'])) {

$c = mysqli_real_escape_string ($mysqli, $trimmed['city']);
} else {
echo '<p class="error">Please enter your city!</p>';

}

//check for a postcode
if (preg_match ('/^[A-Z\'.-]{2,20}$/i',$trimmed['postcode'])) {

$pc = mysqli_real_escape_string ($mysqli, $trimmed['postcode']);
} else {
echo '<p class="error">Please enter your postcode!</p>';

}


//check for a contact number
if (preg_match ('/^[A-Z\'.-]{2,20}$/i',$trimmed['contact_number'])) {

$cn = mysqli_real_escape_string ($mysqli, $trimmed['contact_number']);
} else {
echo '<p class="error">Please enter your Contact Number!</p>';

}

if ($fn && $ln && $e && $p && $fl && $sl && t && c && pc && cn) { // if everything is ok

//make sure the email address is available
$q = "SELECT user_id FROM users WHERE email='$e'";

$r = mysqli_query ($mysqli, $q) or trigger_error("Query: $q\n<br/>MySQL ERROR: " . mysqli_error($mysqli));

if (mysqli_num_rows($r) == 0) { //available.


//Create the activation code:
$a = md5(uniqid(rand(), true));

//add the user to the database
$q = "INSERT INTO users (email, pass, first_name, last_name, first_line, second_line, town, city, postcode, contact_number, active, registration_date) VALUES ('$e', SHA1('$p'), '$fn', '$ln', '$fl', '$sl', 't', 'c', 'pc', 'cn', '$a', NOW() )";

$r = mysqli_query ($mysqli, $q) or trigger_error("Query: $q\n<br/>MySQL Error: " . mysqli_error($mysqli));

if (mysqli_affected_rows($mysqli) == 1)
{ //if it ran ok

//send the email
$body = "Thank you for registering at Teqq.co.uk. To activate your account please click on the link below.\n\n";

$body .= BASE_URL . 'activate.php? x=' . urlencode($e) . "&y=$a";
mail($trimmed['email'], 'Registration Confirmation', $body, 'From: noreply@teqq.co.uk');

//Finish the page
echo '<h3>Thank yopu for registering! A confirmation email has been sent to your address. Please follow the link within the email to activate your account with Teqq.co.uk. </h3>';

exit(); //stop the page

} else { //if it did not run ok.
echo '<p class="error"> Your account could not be registered at this time, please try again later.</p>';
}

} else { // The email address is not available

echo '<p class="error">The email address you have provided already exists in our database, Please try another</p>';
}
} else { // if one of the data tests failed

echo '<p class="error"> Please re-enter your passwords and try again</p>';
}
mysqli_close($mysqli);
}}

?>

<form action="register.php" method="post">
<div class="register">
<p><b>First Name: </b><input type="text" class="register_box" name="first_name" size="20" maxlength="20" value="<?php if (isset($trimmed['first_name'])) echo $trimmed ['first_name']; ?>"/></p>

<p><b>Surname: </b><input type="text" class="register_box" name="last_name" size="20" maxlength="20" value="<?php if (isset($trimmed['last_name'])) echo $trimmed ['last_name']; ?>"/></p>

<p><b>Email Address: </b><input type="text" class="register_box" name="email" size="30" maxlength="80" value="<?php if (isset($trimmed['email'])) echo $trimmed['email']; ?>" /></p>

<p><b>Password:</b> <input type="password" class="register_box" name="password1" size="20" maxlength="20" /> </p>

<p><b>Confirm Password:</b> <input type="password" class="register_box" name="password2" size="20" maxlength="20" /></p>

</div>

<div class="register">

<p><b>First Line: </b><input type="text" class="register_box" name="first_line" size="20" maxlength="20" value="<?php if (isset($trimmed['first_line'])) echo $trimmed ['first_line']; ?>"/></p>

<p><b>Second Line: </b><input type="text" class="register_box" name="second_line" size="20" maxlength="20" value="<?php if (isset($trimmed['second_line'])) echo $trimmed ['second_line']; ?>"/></p>

<p><b>Town: </b><input type="text"  class="register_box" name="town" size="20" maxlength="20" value="<?php if (isset($trimmed['town'])) echo $trimmed ['town']; ?>"/></p>

<p><b>City: </b><input type="text" class="register_box" name="city" size="20" maxlength="20" value="<?php if (isset($trimmed['city'])) echo $trimmed ['city']; ?>"/></p>

<p><b>Postcode: </b><input type="text" class="register_box" name="postcode" size="20" maxlength="20" value="<?php if (isset($trimmed['postcode'])) echo $trimmed ['postcode']; ?>"/></p>
</div>


<p><b>I agree to the Terms and Conditions</b><input name="terms" type="checkbox" value="Terms and Conditions" /></p>



<div align="center"> <input type="submit"  name="submit" value="Register" /></div>
<input type="hidden" name="submit" value="TRUE" />

</form>

Hi

This is the second time i have posted this script. i still cannot get it working..

 

Please help

 

if (isset($_POST['submit'])) { //handle the forms



//trim all the incoming data:

$trimmed = array_map('trim', $_POST);

//Assume invalid values:
$fn = $ln = $e = $p = $fl = $sl = $t = $c = $pc = $cn = FALSE;

//check for a first name
if (preg_match ('/^[A-Z \'.-]{2,20}$/i',$trimmed['first_name'])) {

$fn = mysqli_real_escape_string ($mysqli, $trimmed['first_name']);
} else {

echo '<p class="error">Please enter your first name!</p>';

}

//check for a last name
if (preg_match ('/^[A-Z\'.-]{2,20}$/i',$trimmed['last_name'])) {

$ln = mysqli_real_escape_string ($mysqli, $trimmed['last_name']);
} else {
echo '<p class="error">Please enter your last name!</p>';

}

//check for an email address:
if (preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $trimmed['email'])) {
		$e = mysqli_real_escape_string ($mysqli, $trimmed['email']);

}else {

//check for a password and match against confirm password
if (preg_match ('/^\w{4.20}$/', $trimmed['password1'])) {
if ($trimmed['password1'] == $trimmed['password2']) {

	$p = mysqli_real_escape_string ($mysqli, $trimmed['password1']);
} else {

	echo ' <p class="error">Your password did not match the confirmed password</p>';
}
} else {
echo '<p class="error">Please enter a valid password!</p>';
}

//check for a first line of address
if (preg_match ('/^[A-Z\'.-]{2,20}$/i',$trimmed['first_line'])) {

$fl = mysqli_real_escape_string ($mysqli, $trimmed['first_line']);
} else {
echo '<p class="error">Please enter the first line of your address!</p>';

}


//check for a second line of address
if (preg_match ('/^[A-Z\'.-]{2,20}$/i',$trimmed['second_line'])) {

$sl = mysqli_real_escape_string ($mysqli, $trimmed['second_line']);
} else {
echo '<p class="error">Please enter the second line of your address!</p>';

}

//check for a town
if (preg_match ('/^[A-Z\'.-]{2,20}$/i',$trimmed['town'])) {

$t = mysqli_real_escape_string ($mysqli, $trimmed['town']);
} else {
echo '<p class="error">Please enter your town!</p>';

}


//check for a city
if (preg_match ('/^[A-Z\'.-]{2,20}$/i',$trimmed['city'])) {

$c = mysqli_real_escape_string ($mysqli, $trimmed['city']);
} else {
echo '<p class="error">Please enter your city!</p>';

}

//check for a postcode
if (preg_match ('/^[A-Z\'.-]{2,20}$/i',$trimmed['postcode'])) {

$pc = mysqli_real_escape_string ($mysqli, $trimmed['postcode']);
} else {
echo '<p class="error">Please enter your postcode!</p>';

}


//check for a contact number
if (preg_match ('/^[A-Z\'.-]{2,20}$/i',$trimmed['contact_number'])) {

$cn = mysqli_real_escape_string ($mysqli, $trimmed['contact_number']);
} else {
echo '<p class="error">Please enter your Contact Number!</p>';

}

if ($fn && $ln && $e && $p && $fl && $sl && t && c && pc && cn) { // if everything is ok

//make sure the email address is available
$q = "SELECT user_id FROM users WHERE email='$e'";

$r = mysqli_query ($mysqli, $q) or trigger_error("Query: $q\n<br/>MySQL ERROR: " . mysqli_error($mysqli));

if (mysqli_num_rows($r) == 0) { //available.


//Create the activation code:
$a = md5(uniqid(rand(), true));

//add the user to the database
$q = "INSERT INTO users (email, pass, first_name, last_name, first_line, second_line, town, city, postcode, contact_number, active, registration_date) VALUES ('$e', SHA1('$p'), '$fn', '$ln', '$fl', '$sl', 't', 'c', 'pc', 'cn', '$a', NOW() )";

$r = mysqli_query ($mysqli, $q) or trigger_error("Query: $q\n<br/>MySQL Error: " . mysqli_error($mysqli));

if (mysqli_affected_rows($mysqli) == 1)
{ //if it ran ok

//send the email
$body = "Thank you for registering at Teqq.co.uk. To activate your account please click on the link below.\n\n";

$body .= BASE_URL . 'activate.php? x=' . urlencode($e) . "&y=$a";
mail($trimmed['email'], 'Registration Confirmation', $body, 'From: noreply@teqq.co.uk');

//Finish the page
echo '<h3>Thank yopu for registering! A confirmation email has been sent to your address. Please follow the link within the email to activate your account with Teqq.co.uk. </h3>';

exit(); //stop the page

} else { //if it did not run ok.
echo '<p class="error"> Your account could not be registered at this time, please try again later.</p>';
}

} else { // The email address is not available

echo '<p class="error">The email address you have provided already exists in our database, Please try another</p>';
}
} else { // if one of the data tests failed

echo '<p class="error"> Please re-enter your passwords and try again</p>';
}
mysqli_close($mysqli);
}}

?>

<form action="register.php" method="post">
<div class="register">
<p><b>First Name: </b><input type="text" class="register_box" name="first_name" size="20" maxlength="20" value="<?php if (isset($trimmed['first_name'])) echo $trimmed ['first_name']; ?>"/></p>

<p><b>Surname: </b><input type="text" class="register_box" name="last_name" size="20" maxlength="20" value="<?php if (isset($trimmed['last_name'])) echo $trimmed ['last_name']; ?>"/></p>

<p><b>Email Address: </b><input type="text" class="register_box" name="email" size="30" maxlength="80" value="<?php if (isset($trimmed['email'])) echo $trimmed['email']; ?>" /></p>

<p><b>Password:</b> <input type="password" class="register_box" name="password1" size="20" maxlength="20" /> </p>

<p><b>Confirm Password:</b> <input type="password" class="register_box" name="password2" size="20" maxlength="20" /></p>

</div>

<div class="register">

<p><b>First Line: </b><input type="text" class="register_box" name="first_line" size="20" maxlength="20" value="<?php if (isset($trimmed['first_line'])) echo $trimmed ['first_line']; ?>"/></p>

<p><b>Second Line: </b><input type="text" class="register_box" name="second_line" size="20" maxlength="20" value="<?php if (isset($trimmed['second_line'])) echo $trimmed ['second_line']; ?>"/></p>

<p><b>Town: </b><input type="text"  class="register_box" name="town" size="20" maxlength="20" value="<?php if (isset($trimmed['town'])) echo $trimmed ['town']; ?>"/></p>

<p><b>City: </b><input type="text" class="register_box" name="city" size="20" maxlength="20" value="<?php if (isset($trimmed['city'])) echo $trimmed ['city']; ?>"/></p>

<p><b>Postcode: </b><input type="text" class="register_box" name="postcode" size="20" maxlength="20" value="<?php if (isset($trimmed['postcode'])) echo $trimmed ['postcode']; ?>"/></p>
</div>


<p><b>I agree to the Terms and Conditions</b><input name="terms" type="checkbox" value="Terms and Conditions" /></p>



<div align="center"> <input type="submit"  name="submit" value="Register" /></div>
<input type="hidden" name="submit" value="TRUE" />

</form>

Whats it doing?

  • Author

Whats it doing?

 

Nothing, when you click submit it just reloads the page and clears the pasword feilds, no errors or anything.,

Nothing, when you click submit it just reloads the page and clears the pasword feilds, no errors or anything.,

 

I can not see any onvious issues, You should rewrite it but this time round create a hidden field in your HTML form called token with the value of 1

 

The check:

 

if($_POST['token']) {

 

 

}

 

Sometimes its best to just rewrite the form.

  • Author

I can not see any onvious issues, You should rewrite it but this time round create a hidden field in your HTML form called token with the value of 1

 

The check:

 

 

 

Sometimes its best to just rewrite the form.

what does that do? and where do i put it?

what does that do? and where do i put it?

 

Add a hidden field in your form (hidden fields are not shown on the page but the user will be able to see them if they view source).

<input type="hidden" name="token" value="1" />

 

Replace the

isset($_POST['submit'])

with

isset($_POST['token'])

 

If you do a print_r on $_POST you will find that submit has no value so will trigger a false on isset().

 

You've also forgotten to to write an error message and close the else statement under email address.

Add a hidden field in your form (hidden fields are not shown on the page but the user will be able to see them if they view source).

<input type="hidden" name="token" value="1" />

 

Replace the

isset($_POST['submit'])

with

isset($_POST['token'])

 

If you do a print_r on $_POST you will find that submit has no value so will trigger a false on isset().

 

You've also forgotten to to write an error message and close the else statement under email address.

 

Thanks for helping with this, I was helping another member and could not get back to help this guy.

  • Author

Thanks for helping with this, I was helping another member and could not get back to help this guy.

 

 

The script still isnt working. its so weird...

  • Author

Did u build the script or is it downloaded from somewhere?

 

I wrote it. but i am very new to php

I wrote it. but i am very new to php

 

Dont mean to be rude but i looked at the script and by noooooo way could a person whos very new to php write that, its quite a complex script for a person new to php atleast.

  • Author

Dont mean to be rude but i looked at the script and by noooooo way could a person whos very new to php write that, its quite a complex script for a person new to php atleast.

 

Well i built a content management system and an e-commerce site? the only problem is my registration, so i apreciate your comment but you are wrong. no offence taken though. i just need to get this script working.

Well i built a content management system and an e-commerce site? the only problem is my registration, so i apreciate your comment but you are wrong. no offence taken though. i just need to get this script working.

Yea im sure i am :) anyways if u want i will rebuild it in a simpler form for u to understand and edit :)

  • Author

Yea im sure i am :) anyways if u want i will rebuild it in a simpler form for u to understand and edit :)

 

 

That is an awesome gesture mate thank you.

 

I would still love to know why this script isnt working though.

That is an awesome gesture mate thank you.

 

I would still love to know why this script isnt working though.

 

Could be alot of things its rather messy code and would prob take u posting a database dump on here so one of us developers can troubleshoot it

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.