Page 1 of 3
Registration Problem really need help
Posted: Sat Aug 02, 2008 6:14 pm
by ravx
Hi, basically I have the form in a table and have set all the variable of the text box as $_POST and that is passed to the form handler registrationprocess.php and using $_GET[action] in a switch the php vaildate the form but it does work I think there is a problem with the passing of the $_Post variable of the textbox in the if statement, I have a feeling it something simple im missing maybe, but it does vaildate the form as it check is anything was entered.
Need some help on this from more experienced developer this is my first registration form. Sorry for the messy code.
with the error notification on there are some errors such as undefined constant and variable.
Download the file.
Re: Registration Problem really need help
Posted: Sat Aug 02, 2008 7:01 pm
by jaoudestudios
I had a quick look through, no offence, but you really need to read up on the basics (all languages!)! I will list a few reasons below so hopefully you will be able to look them up quickly and learn from them:
You are using functions in the wrong way, your html is incorrect - you are using upper and lowercase tags, you have everything position:absolute in your css.
Did you write all the code yourself? as some of it is very good and some is not so good.
Dont worry too much about the undefined variables now - notices are less important then warnings. The scripts will still run and work.
I will try and take a proper look tomorrow, but at first glance on the registration page you have some mistakes on line 130, 132, 137 with the php values. You have done it correctly previously so I am not sure if it is a mistake or someone else wrote one of the parts.
Plus dont use print, echo is better.
Catch you tomorrow.
Re: Registration Problem really need help
Posted: Sun Aug 03, 2008 3:33 am
by ravx
Hi, yh i know i just started learning php and using table in html but it is a bit confusing. but if can point out my mistake in the css, html and php that would be great learn from ur mistake as they say, like if you edit the php and send it back that would be a big help. I uploaded a edited version the problems are still there thou.
Thanks alot
Re: Registration Problem really need help
Posted: Sun Aug 03, 2008 4:49 am
by jaoudestudios
Can you tell me which area of the code you think is not working and in which file, or ideally paste the code you think is causing the problem here (and a few lines around it, i.e. about 10 lines max). Then I will be able to tell you if there is anything from with it.
I recommend you learn html first, then css, then php and then mysql; not all at once otherwise you will be a jack of all trades and a master of non - which is the case with so many modern developers.
Re: Registration Problem really need help
Posted: Sun Aug 03, 2008 11:36 am
by ravx
jaoudestudios wrote:Can you tell me which area of the code you think is not working and in which file, or ideally paste the code you think is causing the problem here (and a few lines around it, i.e. about 10 lines max). Then I will be able to tell you if there is anything from with it.
I recommend you learn html first, then css, then php and then mysql; not all at once otherwise you will be a jack of all trades and a master of non - which is the case with so many modern developers.
Just html and css i need to neat up but anyways I think that the variable in the if statement are not being passed on from registration.php to registrationprocess.php as in the switch statement is excuted but when is gets to the if statement the coding breaks up.
1)html code - take this example of the username: <input type="text" name="newusername" value="<?= $_POST[newusername]?>"/>
2) the forms that called registrationprocess.php?action=vaildation:
and in this the code is:
case "vaildation":
if (empty($_POST['newusername']) > 0 && empty($_POST['newpassword']) > 6 && empty($_POST['confirmnewpassword']) > 6 &&
empty($_POST['firstName']) > 0 && empty($_POST['lastName']) > 0 && empty($_POST['address']) > 0 && empty($_POST['post_code']) > 4 && empty($_POST['telephone']) > 10 && empty($_POST['email']) > 0 && empty($_POST['emailconfirm']) > 0 && $_POST[tc] =="checked")
{
I think this code isnt being execute: as for example I tried this code to test the switch:
switch ($_GET[action]) {
case "vaildation":
header('location:
www.google.co.uk');
if (empty($_POST['newusername']) > 0 && empty($_POST['newpassword']) > 6 && empty($_POST['confirmnewpassword']) > 6 &&
empty($_POST['firstName']) > 0 && empty($_POST['lastName']) > 0 && empty($_POST['address']) > 0 && empty($_POST['post_code']) > 4 && empty($_POST['telephone']) > 10 && empty($_POST['email']) > 0 && empty($_POST['emailconfirm']) > 0 && $_POST[tc] =="checked")
{
now the website should redirect to google but it didn't.
I hope this useful.
thanks
Re: Registration Problem really need help
Posted: Sun Aug 03, 2008 1:06 pm
by jaoudestudios
hmmm ok.
Well the best place to start is your if statements, they are incorrect.
Code: Select all
if (empty($_POST['newusername']) > 0 ....)
The code above will not work, you either check for the
empty or for
> 0 (empty will return a boolean result - so
> 6 makes no sense). Start there and let me know how it goes.
Also...
This will not work either, when using $_POST the key must be within quotes if it is not a variable.
i.e. $_POST['tc'] or $_POST[$tc]
Hope that helps
Re: Registration Problem really need help
Posted: Sun Aug 03, 2008 1:14 pm
by ravx
Hi i tried that here is the code, i only tested it with the username:
switch ($_GET[action]) {
case "vaildation":
if (!empty($_POST[newusername]))
{
header('location:
www.google.co.uk');
but it does not redirect to google, im going to make another registration page, but trying to fix maybe difficult.
thanks
Re: Registration Problem really need help
Posted: Sun Aug 03, 2008 1:28 pm
by jaoudestudios
You still have a mistake in your
$_POST &
$_GET
Code: Select all
switch ($_GET['action']) {
case "vaildation":
if (!empty($_POST['newusername'])) {
header('LOCATION:www.google.co.uk');
}
Try that.
After those changes if it still does not work, echo out the GET & POST variables at the top of the script and make sure the variables are coming through. Then we can take it from there.
Re: Registration Problem really need help
Posted: Sun Aug 03, 2008 1:34 pm
by ravx
jaoudestudios wrote:You still have a mistake in your
$_POST &
$_GET
Code: Select all
switch ($_GET['action']) {
case "vaildation":
if (!empty($_POST['newusername'])) {
header('LOCATION:www.google.co.uk');
}
Try that.
After those changes if it still does not work, echo out the GET & POST variables at the top of the script and make sure the variables are coming through. Then we can take it from there.
Hi, i created a simple version where only the suername and password are used this is the html code for this and by the way it worked, i think the quote of the $_get['action'] did it.
html -
<style type="text/css">
.background
{
position:relative;
left: 100px;
top: 340px;
}
#privacy_head {
position:relative;
left: 580px;
top:10px;
}
#reg_title
{
position:absolute;
left:250px;
top:420px;
font-size:xx-large;
}
</style>
<form method=POST action=registration.php?action=vaildation>
<table width="800" border="0" align="center" class=background>
<tr>
<td background="Image/background registration.jpg">
<table background="#000000" border="2px" id="privacy_head" height="50" width="180">
<tr>
<td><p style='font-size:14px; font-weight:bold'>Your Privacy is Important</p></td>
</tr>
<tr>
<td>We do not sell or pass on your information to any organisation without your</td>
</tr>
</table>
<table class="act_form">
<tr>
<td id="reg_title">Registration</td>
<tr> </tr>
<td><strong>*Required</strong></td>
</tr>
<tr>
<tr> </tr>
<td>*Username</td>
<td><input type="text" name="newusername" value="<? $_POST[newusername] ?>"></td>
</tr>
<tr>
<tr> </tr>
<td>*Password</td>
<td><input type="password" name="newpassword" value="<? $_POST[newpassword] ?>"></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</form>
php:
include("preset_registration_1.php");
switch ($_GET['action']) {
case "vaildation":
if (!empty($_POST['newusername'])) {
header('LOCATION:
www.google.co.uk');
}
}
this works so now im going to try to make the full thing and we will see.
but thanks alot for your help, it was some thing simple that was missed.
Re: Registration Problem really need help
Posted: Sun Aug 03, 2008 1:41 pm
by jaoudestudios
No problem, glad it worked
Let my know how you get on with the rest.
Re: Registration Problem really need help
Posted: Sun Aug 03, 2008 1:42 pm
by ravx
jaoudestudios wrote:No problem, glad it worked
Let my know how you get on with the rest.
will do hopefully will get the full thing by today maybe and i got a better understanding of tables thanks to the mistakes lol
Re: Registration Problem really need help
Posted: Mon Aug 04, 2008 3:58 pm
by ravx
ravx wrote:jaoudestudios wrote:No problem, glad it worked
Let my know how you get on with the rest.
will do hopefully will get the full thing by today maybe and i got a better understanding of tables thanks to the mistakes lol
Hi tried to use the method u stated but with teh full it didnt work, i made it simple just to test it and the html code is for username is -
<input type="text" name="newusername" value="<? $_POST['newusername'] ?>">
php -
switch ($_GET['action']) {
case "vaildation":
if (!empty($_POST['newusername']))
{
header('location:
www.google.co.uk');
basically when i press the button it simply go back to the top.
any ideas I tried ith quote and withut and with the ; and without but no luck.
thanks
Re: Registration Problem really need help
Posted: Mon Aug 04, 2008 4:15 pm
by jaoudestudios
echo out your $_GET['action'] and $_POST['newusername'] to make sure they are not emtpy.
<? $_POST['newusername'] ?>
I dont use short cuts so not sure if there is a ; missing at the end of the post.
Use...
Code: Select all
<?php echo $_POST['newusername']; ?>
Short hands are bad habits, as they can be dropped at any time in the new releases of php, then your code wont work! It has happened before.
Re: Registration Problem really need help
Posted: Mon Aug 04, 2008 4:37 pm
by ravx
jaoudestudios wrote:echo out your $_GET['action'] and $_POST['newusername'] to make sure they are not emtpy.
<? $_POST['newusername'] ?>
I dont use short cuts so not sure if there is a ; missing at the end of the post.
Use...
Code: Select all
<?php echo $_POST['newusername']; ?>
Short hands are bad habits, as they can be dropped at any time in the new releases of php, then your code wont work! It has happened before.
I tried to use the <?php echo $_POST['newusername']; ?> but no luck:
html = <input type="text" name="newusername" value="<?php echo $_POST['newusername'] ?>"
and how would i echo the $_GET in the switch statement?
thanks
Re: Registration Problem really need help
Posted: Mon Aug 04, 2008 4:39 pm
by ravx
ravx wrote:jaoudestudios wrote:echo out your $_GET['action'] and $_POST['newusername'] to make sure they are not emtpy.
<? $_POST['newusername'] ?>
I dont use short cuts so not sure if there is a ; missing at the end of the post.
Use...
Code: Select all
<?php echo $_POST['newusername']; ?>
Short hands are bad habits, as they can be dropped at any time in the new releases of php, then your code wont work! It has happened before.
I tried to use the <?php echo $_POST['newusername']; ?> but no luck:
html = <input type="text" name="newusername" value="<?php echo $_POST['newusername']; ?>"
and how would i echo the $_GET in the switch statement?
thanks