Musa
Musa

Reputation: 31

How to change the href of a button?

I have a this:

<input type="submit" class="inputlogin submit" name="register" style="margin-top: 5px;" value="Maak mijn account en log in!">

and then it goes to register/register. I want that it goes to /me, how I can do this?

Upvotes: 0

Views: 145

Answers (7)

Musa
Musa

Reputation: 31

<div class="text" style="font-weight:bold;padding:10px;"><?php if(isset($template->form->error)) { echo '<div class="error-messages-holder"><ul><li><p class="error-message">'.$template->form->error.'</p></li></ul></div>'; } ?>
        <form method="post" action="{url}/me" autocomplete="off">
          <label for="index_rusername">Neem een unieke nickname:</label><br />
          <input type="text" placeholder=" Jouw gebruikersnaam " class="inputlogin" name="reg_username"><br />
          <label for="index_rpassword">Kies een sterk wachtwoord:</label><br />
          <input type="password" placeholder=" Jouw wachtwoord " class="inputlogin" name="reg_password"><br />
          <label for="index_rconpassword">Typ je wachtwoord over:</label><br />
          <input type="password" placeholder=" Jouw wachtwoord " class="inputlogin"  name="reg_rep_password"><br />
          <label for="index_remail">Jouw email adres:</label><br />
          <input type="text" placeholder=" Jouw e-mail adres " class="inputlogin"  name="reg_email"><br />
          <input type="submit" class="inputlogin submit" name="register" style="margin-top: 5px;" value="Maak mijn account en log in!">
        </form>
   </div>
  </div>

I have this code now. But if I press on the button, it doesn't register in the database, so all the configurated things doesn't come in in the table "users".

Upvotes: 0

baao
baao

Reputation: 73251

Another approach would be this:

<input type="button" class="inputlogin submit" style="margin-top: 5px;" value="Maak mijn account en log in!" onclick="parent.location='/me'">

This makes use of onclick and will work without a form. Remember that it doesn't POST a form

Upvotes: 0

Musa
Musa

Reputation: 31

So, I see now that I already had the right code, but it goes to /register/me.. I'm really ashamed...

Upvotes: 0

Musa
Musa

Reputation: 31

I'm really confused right now. So, I have <input type="submit" class="inputlogin submit" name="register" style="margin-top: 5px;" value="Maak mijn account en log in!"> and that I need to change to: <input action="/me" method="get" type="submit" class="inputlogin submit" name="register" style="margin-top: 5px;" value="Maak mijn account en log in!"> maybe I needed this to say earlier, but it's a registration form, so it needs to be checked if everything is filled in, and it needs to get in the database.

Upvotes: 0

Kunjan Thadani
Kunjan Thadani

Reputation: 1670

Your code must be like this:

<form action="/me" method="post">
    <input type="submit" class="inputlogin submit" name="register" style="margin-top: 5px;" value="Maak mijn account en log in!">
</form>

Upvotes: 0

Eugen Rieck
Eugen Rieck

Reputation: 65304

Musa, welcome to stack overflow!

The submit button does exactly what its name says: It submits a form. Now where the form is submitted to is not a property of the submit button, but of the form.

You will find, that the submit button is part of a <form action="..."> .. </form> construct. By changing the action property of the form, you can point it to another URL, e.g. to ' /me'

Upvotes: 1

H4kor
H4kor

Reputation: 1562

The page the input refers to is defined in the action attribute of the <form> not the <input> itself.

<form action="/me" method="get">

Upvotes: 0

Related Questions