nastynate604 Posted November 17, 2009 Share Posted November 17, 2009 Hello All, I am very new to coding with PHP and I need some help with a form that I am creating. It is very basic, and all I need to do is get an email address and a password from a form and then pass that information in a link. The link looks like this: http://my.site.com/validation.aspx?E=$email&P=$password&ID=ADRCOLTC I have my form set up as a "GET" and the action is set up with the link above. When the person hits submit on the form however, the email address is passed as: name%40email.com instead of name@email.com in the link. If anyone can help me out with this or give me some suggestions it would be much appreciated. I know this is a rather noobish question but I can't seem to find the answer anywhere. I found a couple of functions urldecode(); and rawurldecode(); but I can't seem to get those to work and i'm not sure if that is where I need to be looking. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/181901-solved-need-some-help-with-a-form-noob-question/ Share on other sites More sharing options...
genericnumber1 Posted November 17, 2009 Share Posted November 17, 2009 If you're passing a password, you should be using POST. You don't want someone's password popping up in the URL! That said, if you were to stick with using GET (you shouldn't), you can use $_GET['E'] to retrieve name@email.com, the %40 is just the url encoding of the @ symbol. Quote Link to comment https://forums.phpfreaks.com/topic/181901-solved-need-some-help-with-a-form-noob-question/#findComment-959429 Share on other sites More sharing options...
JustLikeIcarus Posted November 17, 2009 Share Posted November 17, 2009 That is the correct way an "@" symbol should be passed in the url. Then urldecode($_GET['E']) should return it to an "@". Quote Link to comment https://forums.phpfreaks.com/topic/181901-solved-need-some-help-with-a-form-noob-question/#findComment-959430 Share on other sites More sharing options...
nastynate604 Posted November 17, 2009 Author Share Posted November 17, 2009 The link only works when the email address (with an @ sign) and the password are visible in the link. I know that sounds incredibly wrong but that is how that link works. At what point within the code do I need to use: urldecode($_GET['email']); Would I use something like this?: $email = urldecode($_GET['email']); Within the Form? Outside the form? Contained within <? ?> in the actual action link? Thank you for your replies! Quote Link to comment https://forums.phpfreaks.com/topic/181901-solved-need-some-help-with-a-form-noob-question/#findComment-959446 Share on other sites More sharing options...
mikesta707 Posted November 17, 2009 Share Posted November 17, 2009 depends on how your code is set up. the page where you get the $_GET variables, and process them should be where you use url_decode. why don't you just use Post? Quote Link to comment https://forums.phpfreaks.com/topic/181901-solved-need-some-help-with-a-form-noob-question/#findComment-959453 Share on other sites More sharing options...
JustLikeIcarus Posted November 17, 2009 Share Posted November 17, 2009 You actually shouldnt even need the urldecode() function. The $_GET['E'] value should have the normal "@" already. $_GET is a php array containing values passed as a query string. So whatever you have that needs to use the submitted email just set <? $email = $_GET['E']; ?> This would be after the form is submitted. Quote Link to comment https://forums.phpfreaks.com/topic/181901-solved-need-some-help-with-a-form-noob-question/#findComment-959459 Share on other sites More sharing options...
nastynate604 Posted November 17, 2009 Author Share Posted November 17, 2009 Ok, let's forget $_GET for a moment. What if I wanted to do this with $_POST variables instead. Here is my form: <form id="form1" name="form1" method="POST" action="http://site.site.com/validation.aspx?E=$email&P=$password&ID=ADRCOLTC"> <table width="100%" border="0" cellspacing="10" cellpadding="0"> <table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td colspan="2" align="center"><strong>Existing Users Please Sign In Below:</strong></td> </tr> <tr> <td align="right">email address:</td> <td><input type="text" name="email" value="" /></td> </tr> <tr> <td align="right">password:</td> <td><input type="password" name="password" value="" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" name="submit" id="submit" value="Submit" /></td> </tr> </table> <tr> <td colspan="2" align="center"> </td> </tr> <tr> <td> </td> </tr> <tr> <td colspan="2" align="center"> </td> </tr> <tr> <td colspan="2" align="center"><p>Please verify your email and password is correct or you<br /> may be taken to the incorrect login page.</p></td> </tr> </form> How would I be able to pass the $email and $password fields from the form into the Link that is contained in the Form Action? I know there is some PHP involved i'm just not sure where to put it.. help! Quote Link to comment https://forums.phpfreaks.com/topic/181901-solved-need-some-help-with-a-form-noob-question/#findComment-959488 Share on other sites More sharing options...
mikesta707 Posted November 17, 2009 Share Posted November 17, 2009 no thats impossible. the variables you are trying to access don't actually exist when you are trying to access them. what exactly are you trying to do? url_decode() theoretically should work, depending on what you are trying to do. However, you could really just set the action to http://site.site.com/validation.aspx and instead of using the $_GET array, use the $_POST array on that aspx page Quote Link to comment https://forums.phpfreaks.com/topic/181901-solved-need-some-help-with-a-form-noob-question/#findComment-959494 Share on other sites More sharing options...
nastynate604 Posted November 17, 2009 Author Share Posted November 17, 2009 Hmm. Ok i'm not really sure if i'm explaining it correctly then. You see the form i've created. I need to take the info that is put into the Email field, and the Password field and when the form is submitted I need that information added to the link under the form action="" So where it says ?E=&P= I need the E= to use what is in the email field and the P= to use what is in the password field. I do not have access to the ASP file on the other end, all I am doing is passing what is contained in the variables to that action link and the .ASPX page is supposed to do the rest. Does this make sense? Quote Link to comment https://forums.phpfreaks.com/topic/181901-solved-need-some-help-with-a-form-noob-question/#findComment-959507 Share on other sites More sharing options...
JustLikeIcarus Posted November 17, 2009 Share Posted November 17, 2009 Oh. Well thats normal get functionality. Just change your forms method="get" and change <input type="text" name="email" value="" /> To <input type="text" name="E" value="" /> And <input type="password" name="password" value="" /> To <input type="password" name="P" value="" /> Quote Link to comment https://forums.phpfreaks.com/topic/181901-solved-need-some-help-with-a-form-noob-question/#findComment-959512 Share on other sites More sharing options...
nastynate604 Posted November 17, 2009 Author Share Posted November 17, 2009 Ok.. so now i'm back to the original issue. When it passes the Email address to the link, it puts it as name%40email.com instead of name@email.com... how do I get around that? Quote Link to comment https://forums.phpfreaks.com/topic/181901-solved-need-some-help-with-a-form-noob-question/#findComment-959563 Share on other sites More sharing options...
nastynate604 Posted November 17, 2009 Author Share Posted November 17, 2009 I fixed it! something just didn't seem right with the link. So what I did was set up the ID as a hidden value in the form and changed the Action link to just say ID= at the end. This worked! it sends all the info through flawlessly. Thanks for all of your help! Quote Link to comment https://forums.phpfreaks.com/topic/181901-solved-need-some-help-with-a-form-noob-question/#findComment-959571 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.