BinaryBird Posted October 16, 2008 Share Posted October 16, 2008 Hi, i am working with a login form using php. I have a problem submitting the form values. Here is the code : <BODY> <div class="main"> <h1>Login Form</h1> <br/><br/> <div class="box"> <form action="process.php" method="post"> <label> <span>Username: </span><input type="text" name="username" value="" /><label/> <label> <span>Password: </span><input type="password" name="password" value="" /><label> </form> <div class="spacer"><a href="process.php" onClick="" class="green">Sign in</a></div> <div class="spacer"> Lost your data? <a href="#">Get your password</a><br/> New User? <a href="#">Sign up</a> </div> </div> </div> </BODY> i am new to both html and php. I understand that if i use a submit button, i can access the form varibles (username & password ) in the process.php page using $_POST. Now if i want to access them by clicking on a link (<div class="spacer"><a href="process.php" onClick="" class="green">Sign in</a></div>) i'm not able to access the same now using the $_POST superglobal. Please help me as to how i can access the form variables in process.php using this method. If i am wrong in writing the code, please correct me. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/128759-solved-help-needed-with-post-method/ Share on other sites More sharing options...
prexep Posted October 16, 2008 Share Posted October 16, 2008 The form isn't being submitted. Quote Link to comment https://forums.phpfreaks.com/topic/128759-solved-help-needed-with-post-method/#findComment-667373 Share on other sites More sharing options...
ngreenwood6 Posted October 16, 2008 Share Posted October 16, 2008 What are you trying to do and why would you need to access them like that? Also, when you post code please use the code tags it is the "#" symbol. Quote Link to comment https://forums.phpfreaks.com/topic/128759-solved-help-needed-with-post-method/#findComment-667381 Share on other sites More sharing options...
BinaryBird Posted October 16, 2008 Author Share Posted October 16, 2008 I am basically trying to create a login form. So that i can take in the username and password from a user and validate it using values from a database. I understand that i need to submit the form using this piece of code <input type="submit" name="submit" value="Submit" /> But i don't want to use the default submit button. I wanted to use a custom button. How do i send the values (i,e username and password) from the login page to a process page using a custom button and not the default button. I am new to html and php. Sorry about not using the code tags earlier. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/128759-solved-help-needed-with-post-method/#findComment-667389 Share on other sites More sharing options...
prexep Posted October 16, 2008 Share Posted October 16, 2008 Check with JavaScript. I think it's like onclick(submitform:'name'). Or something. I'm not well in JS. But it's possible. Quote Link to comment https://forums.phpfreaks.com/topic/128759-solved-help-needed-with-post-method/#findComment-667404 Share on other sites More sharing options...
BinaryBird Posted October 16, 2008 Author Share Posted October 16, 2008 K. Then i need to learn JavaScript too. Any references or links that i can check where its easy to understand. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/128759-solved-help-needed-with-post-method/#findComment-667415 Share on other sites More sharing options...
prexep Posted October 16, 2008 Share Posted October 16, 2008 http://www.w3schools.com gives tutorial. And I found it now onclick="form.submit()" The form should be the name of the form. Example onclick="login.submit()". Just make sure the form is given a name. Quote Link to comment https://forums.phpfreaks.com/topic/128759-solved-help-needed-with-post-method/#findComment-667425 Share on other sites More sharing options...
DarkWater Posted October 16, 2008 Share Posted October 16, 2008 Umm, your HTML is horribly messed up, by the way. I'd fix that before doing anything else. Quote Link to comment https://forums.phpfreaks.com/topic/128759-solved-help-needed-with-post-method/#findComment-667432 Share on other sites More sharing options...
DeanWhitehouse Posted October 16, 2008 Share Posted October 16, 2008 Did you use a html generator? If so learn html, then php and then maybe javascript. Quote Link to comment https://forums.phpfreaks.com/topic/128759-solved-help-needed-with-post-method/#findComment-667435 Share on other sites More sharing options...
prexep Posted October 16, 2008 Share Posted October 16, 2008 Or learn HTML, CSS, PHP, and JS. Only learn JS if you have a very good understanding HTML. If not JS is useless. Quote Link to comment https://forums.phpfreaks.com/topic/128759-solved-help-needed-with-post-method/#findComment-667439 Share on other sites More sharing options...
BinaryBird Posted October 16, 2008 Author Share Posted October 16, 2008 I guess i'll start of with HTML and CSS. Thanks for all the help. Quote Link to comment https://forums.phpfreaks.com/topic/128759-solved-help-needed-with-post-method/#findComment-667452 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.