FutureWebDeveloper Posted April 27, 2013 Share Posted April 27, 2013 Ok I' ve studied PHP online for about 3 weeks now, and went through some online tutorials through http://www.afterhoursprogramming and I know the stuff on there is valid because it matches up with W3SCHOOL.COM and php.net, and others. However, I' am having a problem with forms. Here is the HTML side <!DOCTYPE html><html><head><style>input[type="text"]{ width:150px; display:block; margin-bottom:10px; background:yellow;}input[type="password"]{ width:150px; display:block; margin-bottom:10px; background:red;}input[type="submit"]{ width:150px; height:100px; line-height:100px; background:black; color:white;}</style><meta http-equiv="Content" content="text/html; charset=UTF-8"/><title>Web Form 1</title></head><body><h1>Web Form</h1><form action="php-form1.php" method="post"> <label>User Name: <input type="text" name="un"/> </label><br> <label>Password: <input type="password" name="pw"/> </label><br> <input type="submit" value="Send Information" name="sender"/></form></body></html> and here is the PHP script <?php# simple php script for a Web Form// this script is used in combination with my form1.html$userName;$passWord;if(isset($_POST['sender'])){$userName=$_POST["un"];$passWord=$_POST["pw"];}echo $userName . " is your username and " . $passWord . " is your password";?> I would also like to mention that I' am using XAMMP , and the apache wasn't able to use my PORT 80, so I changed it to port 8080 and 443, basic PHP scripts are able to run, but whenever I try this it doesn't. Also the PHP file and the HTML file of the code I posted above are in the same folder. Sorry once again for the newbie question. Please help. Oh also when I run the program, it says error on Line 14 (where the echo function is at). Link to comment Share on other sites More sharing options...
jeffman Posted April 27, 2013 Share Posted April 27, 2013 try to var_dump($_POST) and see what data the script actually receives. Note that expressions like $userName; don't do anything. The error you're getting on 14 probably means $userName isn't set to anything. If it should have a default value, assign it something Link to comment Share on other sites More sharing options...
FutureWebDeveloper Posted April 27, 2013 Author Share Posted April 27, 2013 try to var_dump($_POST) and see what data the script actually receives. Note that expressions like $userName; don't do anything. The error you're getting on 14 probably means $userName isn't set to anything. If it should have a default value, assign it something Maybe I should set $userName = $_POST["un]; Because I know that the first two variables are undefined since I didn't assign a value to them, but later I assign them a value, but I will try what you recommended. Link to comment Share on other sites More sharing options...
FutureWebDeveloper Posted April 27, 2013 Author Share Posted April 27, 2013 Ok I just tried the Code out without the var_dump at 000webhost.com where I host my websites, and it worked, I think there's a problem with my XAMMP (even though it runs simple php programs correctly). I will do more research on the VAR_DUMP though cause was trying to figure out where to put it Hahaha. Yep I' am a Noob. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now