why isn't html passing the first variable to php

They have: 461 posts

Joined: Jul 2003

the following is the display for page 4. the issue is that the variable step is not being passed back to php at this point causing the form to restart instead of validate.

i'm trying to work out all php issues in the sign up before adding the db and the username check

for the full code: http://people.brandeis.edu/~m3rajk/JMT/preview/phpprev/signup.txt
to run through the page: http://people.brandeis.edu/~m3rajk/JMT/preview/phpprev/signup.php

thank you in advance for the help. i would like to know WHY the step variable is not being passed.

<?php
function s4(){
        <
h1>THIS IS A TEST. IT DOES NOT HAVE A DATABASE CONNECTION NOR DOES IT CHECK USERNAMES. THIS LINE WILL BE REMOVED IN THE REAL ONE </h1>
     
      <
p>Thank you for your interest in joining FindYourDesire.com. We need to know some things about you in order to make your profile here. Any feild in <font color=\"#ff0000\">RED</font> is required. Any feild marked with an * is confidential and will NOT show up in your user stats. Any feild with a &#176; will not show up in your user stats, but is collected for future features. You will be notified before they are used.</p>
      <h2>NOTE: MAXIMUM PICTURE SIZE IS 150 KB</h2>
      <form enctype=\"multipart/form-data\" action=\" echo
$_SERVER[PHP_SELF]; \" method=\"POST\">
   <input type=\"hidden\" name=\"step\" value=\"5\"><input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"153600\">
   <table frame=\"void\" bgcolor=\"#000000\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" text=\"#c8c8c8\">
       <tr><td>Your <a name=\"#confcode\" href=\"#confcode\" onClick=\"window.open('faq.php?seek=confcode', 'faq', 'width=500,height=250,scrollbars=yes');\">Confirmation Code</a></td><td><input type=\"text\" name=\"conf\" size=\"25\"></td></tr>
       <tr><td>Upload your main picture</td><td><input type=\"file\"  accept=\"image/jpeg\" name=\"main\" size=\"25\"></td></tr>
       <tr><td>Upload Thumb 1</td><td><input type=\"file\"  accept=\"image/jpeg\" name=\"t1\" size=\"25\"></td></tr>
       <tr><td>Upload Thumb 2</td><td><input type=\"file\"  accept=\"image/jpeg\" name=\"t2\" size=\"25\"></td></tr>
       <tr><td>Upload Thumb 3</td><td><input type=\"file\"  accept=\"image/jpeg\" name=\"t3\" size=\"25\"></td></tr>
       <tr><td>Upload Thumb 4</td><td><input type=\"file\"  accept=\"image/jpeg\" name=\"t4\" size=\"25\"></td></tr>
       <tr><td>Upload your <a name=\"#salute\" href=\"#salute\" onClick=\"window.open('faq.php?seek=salute', 'faq', 'width=500,height=250,scrollbars=yes');\">salute</a></td><td><input type=\"file\"  accept=\"image/jpeg\" name=\"salute\" size=\"25\"></td></tr>
       <tr><td><input type=\"submit\" value=\"Go To The Next Step\"></td><td><input type=\"reset\" value=\"Restart This Step\"></td></tr>
   </table>
    </center>
  </body>
</html>

}
?>

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

They have: 10 posts

Joined: Jun 2003

A quick glance show me that your form create step variables in local scope. You need to declare $step globally, outside the function and then pass it via global $step declaration.

They have: 461 posts

Joined: Jul 2003

the preveious step value is irrelvant when i make the page, thus the step valalue is HARD CODED to THIS page.
yet when you submit step 4, it's never set if you look at the full code, it RESTARTS after step 4. ie: acts like the first time you call it.

that is what i mean when i say yhe variable is not being passed at THIS point. meaning after step 1, 2 and 3, it gets passed
in all of them, it's done the same way

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

They have: 461 posts

Joined: Jul 2003

Quote: Originally posted by pbhulipo
A quick glance show me that your form create step variables in local scope. You need to declare $step globally, outside the function and then pass it via global $step declaration.

how so?
i purposely did not pass step to this function. ther is no need to.
i create the valut that gets put into the post array for the next time the form is submitted within this function

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

I see no reason the step value should not be passed. My guess is that the error is in the receiving end of the form.

They have: 461 posts

Joined: Jul 2003

that's my guess too, but i don't understand why php is not setting it after the fourth time.
the debugging line i have put in clearly shows that step doesn't get set when you submit the 4th page, reverting to the default...and restarting the user.

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

They have: 93 posts

Joined: Jun 2003

I looked at the code. To make it easier for people to read encase my comment isnt the fix, try pastebin.com

Looking at your code, I never see where you have echo'ed the value of step to check its value.

When I looked for what you had in the elseif banch you have nothing for the 4th step it is an empty elseif branch.

So if is blank then that if structure is ended because it met the value and had nothing to do. It would then proceed on. Right after that you have your errors section...then all functions. So you have NOTHING to happen for that page.

Running the script is appears you have fixed it, but encause it worked me me alone that was all I could find in the txt file.

[Design Alpha] -Web Services : Design,Hosting,Advertising,Software
Ask about custom pricing on hosting!!
Site Assets: [UltraGaming.com] [Blades of Warcraft]

They have: 461 posts

Joined: Jul 2003

umm.. top of the first page. i wanted to see what was happening when it got bounced back. that's the ONLY place it gets echoed to see the title.

if you would be so kind as ot read the code again, aside form the changes, i DO check the value of step. i do so to control WHAT is to be done at each step. what is to be checked

you looked AFTER i started the changes to keep what's been entered if there was an issue in step 2

btw: step is ALWAYS echoed int he title

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

I don't see anything wrong with your code.

Try adding this somewhere ...
print_r($_POST);

Make sure that $_POST['eye'] and $_POST['spt'] contain a valid value.

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 461 posts

Joined: Jul 2003

http://people.brandeis.edu/~m3rajk/JMT/preview/phpprev/signup.txt
http://people.brandeis.edu/~m3rajk/JMT/preview/phpprev/signup.php

between the changes in the sign up, i figured it's time to start fresh. so here's what's going on right now....

issue 1 (most problematic) -- step does not get picked up by php after submission of step 4. step 4 is created by this function

<?php
function s4(){
        <
h1>THIS IS A TEST. IT DOES NOT HAVE A DATABASE CONNECTION NOR DOES IT CHECK USERNAMES. THIS LINE WILL BE REMOVED IN THE REAL ONE </h1>
     
      <
p>Thank you for your interest in joining FindYourDesire.com. We need to know some things about you in order to make your profile here. Any feild in <font color=\"#ff0000\">RED</font> is required. Any feild marked with an * is confidential and will NOT show up in your user stats. Any feild with a &#176; will not show up in your user stats, but is collected for future features. You will be notified before they are used.</p>
      <h2>NOTE: MAXIMUM PICTURE SIZE IS 150 KB</h2>
      <form enctype=\"multipart/form-data\" action=\" echo
$_SERVER[PHP_SELF]; \" method=\"POST\">
    <input type=\"hidden\" name=\"step\" value=\"5\"><input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"153600\">
    <table frame=\"void\" bgcolor=\"#000000\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" text=\"#c8c8c8\">
        <tr><td>Your <a name=\"#confcode\" href=\"#confcode\" onClick=\"window.open('faq.php?seek=confcode', 'faq', 'width=500,height=250,scrollbars=yes');\">Confirmation Code</a></td><td><input type=\"text\" name=\"conf\" size=\"25\"></td></tr>
        <tr><td>Upload your main picture</td><td><input type=\"file\"  accept=\"image/jpeg\" name=\"main\" size=\"25\"></td></tr>
        <tr><td>Upload Thumb 1</td><td><input type=\"file\"  accept=\"image/jpeg\" name=\"t1\" size=\"25\"></td></tr>
        <tr><td>Upload Thumb 2</td><td><input type=\"file\"  accept=\"image/jpeg\" name=\"t2\" size=\"25\"></td></tr>
        <tr><td>Upload Thumb 3</td><td><input type=\"file\"  accept=\"image/jpeg\" name=\"t3\" size=\"25\"></td></tr>
        <tr><td>Upload Thumb 4</td><td><input type=\"file\"  accept=\"image/jpeg\" name=\"t4\" size=\"25\"></td></tr>
        <tr><td>Upload your <a name=\"#salute\" href=\"#salute\" onClick=\"window.open('faq.php?seek=salute', 'faq', 'width=500,height=250,scrollbars=yes');\">salute</a></td><td><input type=\"file\"  accept=\"image/jpeg\" name=\"salute\" size=\"25\"></td></tr>
        <tr><td><input type=\"submit\" value=\"Go To The Next Step\"></td><td><input type=\"reset\" value=\"Restart This Step\"></td></tr>
    </table>
    </center>
  </body>
</html>

}
?>
issue 2 (annoying but doesn't need to be resolved before i go further with this) -- error checking on aim, icq, msn and yim gets set off for empty entries. right now i'm not sure if it's setting the variables to empty strings or to null. i haven't had a chance to test this. i'm also not sure how to maniuplate the preg_match so that it makes sure the entire string fits the pattern? checks on these
<?php
   
# check that aim/msn/yim are valid
   
if((isset($aim))&&(!(preg_match('/^[\w\- ]+$/', $aim)))){
     
$warn=TRUE; $badaim=TRUE;
     
$warns[]='Your AIM sn looks to be invalid. If you had no errors in the required, then it was not entered. Please go to your site control panel after signing in if you wish to have it public.';
    }
    if((isset(
$icq))&&(!(preg_match('/^\d+$/', $icq)))){
     
$warn=TRUE; $badicq=TRUE;
     
$warns[]='Your icq uid looks to be invalid. If you had no errors in the required, then it was not entered. Please go to your site control panel after signing in if you wish to have it public.';
    }
    if((isset(
$msn))&&(!(preg_match('/^[\w\-\.]+(@[\w\.\-]+\.\w\w\w?)?/', $msn)))){
     
$warn=TRUE; $badmsn=TRUE;
     
$warns[]='Your MSN id/email looks to be invalid. If you had no errors in the required, then it was not entered. Please go to your site control panel after signing in if you wish to have it public.';
    }
    if((isset(
$yim))&&(!(preg_match('/^[\w\- ]+$/', $yim)))){
     
$warn=TRUE; $badyim=TRUE;
     
$warns[]='Your YIM sn looks to be invalid. If you had no errors in the required, then it was not entered. Please go to your site control panel after signing in if you wish to have it public.';
    }
?>
issue 3 (actually it's more of a question since i haven't added the db yet since i want to be sure all the php is working first) -- when trying a query, does the return when it's not there come through as NULL 'false' 0 or some other sign of not getting a match? ie: would [php
<?php
    $db
=mysql_connect(Ashes, visitor, visitor);
   
$user=mysql_query("SELECT * FROM (main table) WHERE user=$un",$db);#<--- main table not set
   
elseif(!($user)){$err=TRUE; $errs[]='That username is already in use. Please choose a new username.'; $step=2;}
?>
[/php] work?

thanx in advance for your insight.

-m3rajk

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

1 - I have no idea what's wrong.

2 - Test for an empty string. The vars will always be set, but will not always contain a value.

3 - !$user will be true if the query fails. You want mysql_num_rows($user)>0.

Mark Hensler
If there is no answer on Google, then there is no question.

druagord's picture

He has: 335 posts

Joined: May 2003

did you try putting the hidden field step after the MAX_FILE_SIZE or after the file field when all else fails this kind of thing might help

They have: 461 posts

Joined: Jul 2003

druagord: i tried that and it didn't work

mark: i tried to test issue 2 against ' ' and ... dammit! empty string should be '' not ' ' let me try that. and thank you for the response on number 3. that was part of why there isn't an actual check on the username yet. i wasn't sure how mysql would return a check on the name (the other part being the lack of validation so i haven't made the db since i've been tweaking things... also because mysql is not making users when i give it the line "GRANT USAGE TO visitor IDENTIFIED BY visitor"

i want to make a few levels int he hopes i can have a few on whatever server space i get, so that if something happens and someone gets a page they shouldn't get to they won't have any added abilities, so the possible damage will be limited

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

They have: 461 posts

Joined: Jul 2003

i changed

<?php
   
if((isset($aim))&&(!(preg_match('/[\w\- ]+/', $aim)))){
     
$warn=TRUE; $badaim=TRUE;
     
$warns[]='Your AIM sn looks to be invalid. If you had no errors in the required, then it was not entered. Please go to your site control panel after signing in if you wish to have it public.';
    }
?>
to
<?php
   
if((isset($aim))&&((!(preg_match('/^[\w\- ]+$/', $aim)))||(!(preg_match('/^$/'))))){
     
$warn=TRUE; $badaim=TRUE;
     
$warns[]='Your AIM sn looks to be invalid. If you had no errors in the required, then it was not entered. Please go t\
o your site control panel after signing in if you wish to have it public.'
;
    }
?>
to test that
if i'm not mistaken that changes the match from merely having word characters, to being only word characters, or nothing. i'll repost back after testing. if someone could just assure me i did it right if the blank entry works (the first part's manipulation) it would be nice to know that i got it working right

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

They have: 461 posts

Joined: Jul 2003

the string: !@#$%^&*)asdfsad is still being called ok while a blank entry is coming up as bad

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

if ($aim=='' || !preg_match('/^(\w| )+$/', $aim)) {
'You're doing it the hard way trying to preg_match() everything. If simple string comparisions will do, use them. They are much easier on system resources and execute faster. I don't know what a valid AIM looks like, so I just used work characters and spaces.

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 461 posts

Joined: Jul 2003

when you sign up for aim, it doesn't let you use spaces, those are formatting after, but still limited to 16 characters. as far as i know, only characters matched in \w are allowed

after checking with aim.com....

valid aim characters: 3-16 letters or numbers, must begin with a letter

so \w{3,16} and \w\w\w+ with the feild restricted to 16 characters on input works.
now those are working. back to the original issue... the step not being picked up

just an issue with looks. i'm going to remove the border, but the button wont move with valign. the rest will. i don't understand why (this is for the nav bar. i added it to the signup since it's in some. both of the graphics people have pressing issues right now (one's mom died the other one was having a breakdown and i couldn't figure out why, the fact they come to me shows the type of person i am. it wouldn't be right to talk of the site right now with them or ask for graphics. they need someoen who'll sit and listen and just be there for them) so i'm trying to get a text version up and running... the signup is the missing link right now. wellthe "navigation bar" issue is just ie. mozilla and netscape display right. still, i expect most to use ie. if i make it top for valign and get rid of the border, it should look ok

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

They have: 461 posts

Joined: Jul 2003

i inserted another debugging line that proves that NOTHING is being passed at step 4. i tried something on a hunch...

http://people.brandeis.edu/~m3rajk/JMT/preview/phpprev/varsignup.php

in this one i changed:
to:

it works there, but i don't know if the pictures would upload (i don't think i have access to the upload directory on that server, please don't try to test that) would it upload right without that line?

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

They have: 461 posts

Joined: Jul 2003

from elsewhere....

Quote: Originally posted by nikolai
Okay -- look closely at your phpinfo() output. What's the value of "file_uploads"?

No value! PHP isn't configured to handle or allow file uploads. My guess is that PHP sees an incoming file, knows it's not configured to handle it, so throws away the incoming data.

The only thing to do is to ask the system administrator to enable file uploads in PHP. For security reasons, they should also upgrade PHP to the latest stable version.

Take care,

Nik
http://www.bigaction.org/

nice to know that. since it works without the file uploads, it should work when i move off this.

that means i've been playing with this for a few weeks pointlessly. oh well. it helped me tweak a bunch of things prior to getting to the db

POSIX. because a stable os that doesn't have memory leaks and isn't buggy is always good.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.