form coding

Thread Solved

Join Date: Mar 2008
Posts: 4
Reputation: austin-khoi is an unknown quantity at this point 
Solved Threads: 0
austin-khoi austin-khoi is offline Offline
Newbie Poster

form coding

 
0
  #1
Mar 29th, 2008
i have a problem with my form. there are 2 button : a login and a register button . login but will redirect to welcome.php, register to register.php. i put the action in the form like this
<form name="login" method="post" action="welcome.php" >
the problem is both buttons turn me to welcome.php, how can i solve this ? thanks alot
Quick reply to this message  
Join Date: Mar 2008
Posts: 154
Reputation: Suomedia is an unknown quantity at this point 
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: form coding

 
0
  #2
Mar 29th, 2008
You must close each form with </form> and make sure that one form is not within another.


Matti Ressler
Suomedia
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Quick reply to this message  
Join Date: Mar 2008
Posts: 4
Reputation: austin-khoi is an unknown quantity at this point 
Solved Threads: 0
austin-khoi austin-khoi is offline Offline
Newbie Poster

Re: form coding

 
0
  #3
Mar 30th, 2008
then, how can put the 2 button within a row ?
Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: form coding

 
0
  #4
Mar 30th, 2008
  1. <html>
  2. <body>
  3. <form method="post" name="test">
  4. <input type="button" name="button1" value="login" onClick="javascript:
  5.  
  6. document.test.action='login.php';document.test.submit();"><input type="button" name="button2" value="Register"
  7.  
  8. onClick="javascript: document.test.action='register.php';document.test.submit();">
  9. </form>
  10. </body>
  11. </html>

You can do it this way.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Quick reply to this message  
Join Date: Mar 2008
Posts: 4
Reputation: austin-khoi is an unknown quantity at this point 
Solved Threads: 0
austin-khoi austin-khoi is offline Offline
Newbie Poster

Re: form coding

 
0
  #5
Mar 31st, 2008
wow great, thanks alot
Quick reply to this message  
Join Date: Mar 2008
Posts: 154
Reputation: Suomedia is an unknown quantity at this point 
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: form coding

 
0
  #6
Mar 31st, 2008
And if the user has javascript turned off? Nothing happens, not good.

Your are far better to structure you page in such a way as to not depend on javascript.

Most login/register pages have form inputs for username and password for registered members, and a simple linked button to the registration page if the user is not registered:


  1. <html>
  2. <body>
  3. <form method="post" name="test" action='welcome.php';>
  4. <input type="submit" name="button1" value="login"><a href="register.php"><input type="button" name="button2" value="Register"></a>
  5. </form>
  6. </body>
  7. </html>


Matti Ressler
Suomedia
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: form coding

 
0
  #7
Mar 31st, 2008
If javascript is disabled, even the form validation/ajax wouldn't work.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Quick reply to this message  
Join Date: Mar 2008
Posts: 154
Reputation: Suomedia is an unknown quantity at this point 
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: form coding

 
0
  #8
Mar 31st, 2008
Originally Posted by nav33n View Post
If javascript is disabled, even the form validation/ajax wouldn't work.

What Ajax? A well written script will function without either javascript or Ajax. A good example: http://holyculturedownload.com/

This is a heavily Ajaxed site. Turn off javascript and it is still functional - this allows it to have Google results like this and for users to still browse the site.

A form should not rely only on javascript for validation - the PHP side should also check the $_POST data.


Matti Ressler
Suomedia
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: form coding

 
0
  #9
Mar 31st, 2008
What Ajax? A well written script will function without either javascript or Ajax. A good example: http://holyculturedownload.com/
That unfortunately, didn't work in FF2 when I disabled javascript. Click on the "Listen" button to test. Strangely, even gmail's "send" button didn't work when I disabled javascript.
A form should not rely only on javascript for validation - the PHP side should also check the $_POST data.
Yes, ofcourse.
Last edited by nav33n; Mar 31st, 2008 at 3:19 pm.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Quick reply to this message  
Join Date: Mar 2008
Posts: 154
Reputation: Suomedia is an unknown quantity at this point 
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: form coding

 
0
  #10
Mar 31st, 2008
Originally Posted by nav33n View Post
That unfortunately, didn't work in FF2 when I disabled javascript. Click on the "Listen" button to test. Strangely, even gmail's "send" button didn't work when I disabled javascript.

Now that is pedantic... the "listen" button is clearly a javascript/Ajax control. The point was that the SITE functions without javascript for the purpose of search engine indexing (which it does very well).... I dont believe that Googlebot listens to music

I think you will find that the signup page functions quite fine without Javascript (it does have it).


Similarly, forms should be designed not to be dependent on Javascript to accomplish their purpose. That Gmail fails for something so fundamental is surprising, but not acceptable.


Matti Ressler
Suomedia
Last edited by Suomedia; Mar 31st, 2008 at 4:39 pm.
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Quick reply to this message  
Closed Thread

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC