User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 427,376 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,989 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1336 | Replies: 22 | Solved
Closed Thread
Join Date: Mar 2008
Posts: 4
Reputation: austin-khoi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
austin-khoi austin-khoi is offline Offline
Newbie Poster

form coding

  #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
AddThis Social Bookmark Button
 
Join Date: Mar 2008
Posts: 153
Reputation: Suomedia is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: form coding

  #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
 
Join Date: Mar 2008
Posts: 4
Reputation: austin-khoi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
austin-khoi austin-khoi is offline Offline
Newbie Poster

Re: form coding

  #3  
Mar 30th, 2008
then, how can put the 2 button within a row ?
 
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: form coding

  #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.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

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

Re: form coding

  #5  
Mar 31st, 2008
wow great, thanks alot
 
Join Date: Mar 2008
Posts: 153
Reputation: Suomedia is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: form coding

  #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:


<html>
<body>
<form method="post" name="test" action='welcome.php';>
<input type="submit" name="button1" value="login"><a href="register.php"><input type="button" name="button2" value="Register"></a>
</form>
</body>
</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
 
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: form coding

  #7  
Mar 31st, 2008
If javascript is disabled, even the form validation/ajax wouldn't work.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
 
Join Date: Mar 2008
Posts: 153
Reputation: Suomedia is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: form coding

  #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
 
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: form coding

  #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 2:19 pm.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
 
Join Date: Mar 2008
Posts: 153
Reputation: Suomedia is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: form coding

  #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 3:39 pm.
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
 
Closed Thread

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:58 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC