473,382 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

returning to signup form

hi

i have a basic signup POST form, with php on the same page. how do i
return to this page with all the entries still present, yet with a
message at the top, for when the user enters one invalid entry?

cheers
dave
Jul 17 '05 #1
3 2162

"David" <da********@gmail.com> schreef in bericht
news:f3**************************@posting.google.c om...
hi

i have a basic signup POST form, with php on the same page. how do i
return to this page with all the entries still present, yet with a
message at the top, for when the user enters one invalid entry?

cheers
dave


I consider you will write to a database in the same php page and then
redirect to another page

Put this in the top of your page:

if($Submit) { // Submit is the name of your submit button

if(!$name || !$street) { # if for example name or street not filled in
# generate errormessage
if(!$name) {$err .= "Name not filled in";}
if(!$street) {$err .= "Street not filled in";}
} else {

# alle input ok, here you can put your sql queries to interact
with the database

header("Location: nextpage.php");
exit;
}

}

Marcel
Jul 17 '05 #2
While the city slept, David (da********@gmail.com) feverishly typed...
hi
Ay up,
i have a basic signup POST form, with php on the same page. how do i
return to this page with all the entries still present, yet with a
message at the top, for when the user enters one invalid entry?


If you are posting the results to the page, then write them into the default
values for the input elements. Something like;

<html>
<head>
<!-- head stuff here -->
</head>
<body>

<?php

$defaultName = "Enter your name here"
$defaultEmail = "Enter your email address here"
$formError = false;

if($_POST['update'] == 1) {
$name = $_POST['name'];
$email = $_POST['email'];
if(($name == "") || ($email == "")) {
$formError = true;
print("<p>Error on form.</p>");
if($name == "") {
print("<p>Please enter a value for Name</p>");
}
else {
$defaultName = $name;
}
if($email == "") {
print("<p>Please enter a value for Email Address</p>");
}
else {
$defaultEmail = $email;
}
}
else {
print("<p>Thanks for your input!</p>");
// write the form contents to your database, or whatever
}
}

if ((!isset($update)) || ($formError)) {
?>

<form action = "thispage.php?update=1" method="post">
<p>Name: <input type="text" name="name" value="<?=$defaultName?>"></p>
<p>Email Address: <input type="text" name="email"
value="<?=$defaultEmail?>"></p>
<input type = "submit" name="submit" value="Submit">
</form>
<?
}
?>

</body>
</html>

.... Note: This is straight off the top of my head! Not tested or anything!

Hope that helps,
Nige

--
Nigel Moss
http://www.nigenet.org.uk
Mail address not valid. ni***@DOG.nigenet.org.uk, take the DOG. out!
In the land of the blind, the one-eyed man is very, very busy!
Jul 17 '05 #3
think i get it now. cheers guys

dave
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Rudi Ahlers | last post by:
I tried the following: http://intranet/signup.php?Domain=newdomain.com, and it doesn't seem to return any values In my script I have the following: <? print $_POST; $DomainName = $_POST;...
7
by: deko | last post by:
Why is $_SERVER returning multiple IP Addresses? Actually, I'm not sure if it's $_SERVER -- or which if/else statement -- that's the problem, but what I'm getting as a value for $visip looks...
3
by: Dustin | last post by:
I am developing a website where users can sign up for a service. They essentially can become a memeber. It will allow anyone to sign up, but I need to make it so only humans can sign up. I need...
2
by: .Net Sports | last post by:
I need to find a script that whereas a user signs up for your website and when he hits submit, an email goes to his email box with a confirmation link (generated by random number) for him to click...
0
by: jon | last post by:
Hey, i've been trying to create a signup page that asks for a username, password and then to confirm the password. It is suppose to check how long both of them are, and if the passwords line up,...
2
by: fredtbx | last post by:
Using ASP.NET 2.0 Login control and CreateUserWizard Hi, I can't figure out how, when I have the Login control up on Login.aspx and if the user doesn't have an account, to point to Signup.aspx...
1
by: kang jia | last post by:
hi when user entered particulars in signuppage and click" signup" button, i will direct them to do_signup.php. if say the NRIC is dupicate in datebase, i will redirect them back to signup page...
2
by: nazgul42 | last post by:
Ok... this is my third problem today, but here goes: On my signup page for my login system on my website, I have some code that is supposed to check if a username is already taken and give an error...
0
by: david220 | last post by:
hi once members sign up to my site they get sent an email which contains there username/password which they enter on a sign up form. Once they've signed up the email is automatically sent using...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.