I have a problem with this form, no matter which method I use (POST or GET), it doesn't send the request parameters email and pass.
<!DOCTYPE html>
<html>
<body>
<form action="controller/connect_user.php" method="GET">
<label for="email">Email:</label>
<input type="email" id="email" required>
<label for="pass">Password:</label>
<input type="password" id="pass" required>
<button type="submit">Connect</button>
</form>
</body>
</html>
The problem doesn't come from the adress in action, the file is well referenced.
I know I shouldn't use GET for sensitive data, but I used this method because it allows me to see easily the parameters in the URL.
Thank you for your help.
you need to use name attribute to pass data like this:
<form action="controller/connect_user.php" method="GET">
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="pass">Password:</label>
<input type="password" id="pass" name="password" required>
<button type="submit">Connect</button>
instead of this:
<form action="controller/connect_user.php" method="GET">
<label for="email">Email:</label>
<input type="email" id="email" required>
<label for="pass">Password:</label>
<input type="password" id="pass" required>
<button type="submit">Connect</button>
</form>
After you can get thhose values like this:
$email = $_GET['email'];
$password = $_GET['password'];
I recommend to you to use POST instead of GET
You need to give your inputs a name:
<form action="controller/connect_user.php" method="GET">
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="pass">Password:</label>
<input type="password" id="pass" name="password" required>
<button type="submit">Connect</button>
</form>
Then, in your PHP you can access them like:
echo $_POST['name'];
A input needs a name-attribute, otherwise there is no possiblity to get it (through GET or POST)
<input type="password" id="pass" name="pass" required>
Related
I have a simple html formula with many input fields:
<input type="text" id="vorname" name="vorname" placeholder="Vorname" autocomplete="given-name" required>
<input type="text" id="nachname" name="nachname" placeholder="Nachname" autocomplete="family-name" required>
<input type="text" id="firma" name="firma" placeholder="Firma" autocomplete="organization">
<input type="text" id="strasse" name="strasse" placeholder="Straße" autocomplete="address-level2" required>
<input type="text" id="plz" name="plz" placeholder="PLZ" maxlength="5" pattern="[0-9]+" autocomplete="postal-code" required>
<input type="text" id="ort" name="ort" placeholder="Ort" autocomplete="street-address" required>
<input ype="email" id="email" name="email" placeholder="E-Mail" autocomplete="email" required>
<input type="tel" id="tel" name="tel" placeholder="Telefon" pattern="[0-9]+" autocomplete="tel" required>
If I call the website with my iPhone and I click on the first input "vorname" I get the option "Fill contact automatically".
All values will be filled automatically except "nachname","firma","Straße","PLZ"
On Safari (macOS) I get no option to filled any fields.
Where is my mistake?
I have a registration form made by the following fields (extract from the code):
<form role="form" id="profile_form" class="contact-form" autocomplete="off">
<input type="text" name="mail" class="input-box form-control" autocomplete="off">
<input type="text" name="nome" class="input-box form-control" autocomplete="off">
<input type="text" name="cognome" class="input-box form-control" autocomplete="off">
<input type="password" name="password" id="password" placeholder="Password" class="input-box form-control" autocomplete="off">
<input type="password" name="verify_password" placeholder="Verifica password" class="input-box form-control" autocomplete="off">
</form>
Firefox is considering cognome field to be the username holder and so on form submitting it is asking to save the password as password (that's fine) and the cognome field as username.
What am I doing wrong here? How am I going to tell firefox to take the email as username?
I am writing the following HTML code which requires certain input values and has a submit button which redirects to a different site when clicked. Currently the Submit button redirects even if no value is entered into the input boxes. I want the submit button to only work if all the input values are filled.
<!DOCTYPE html>
<html>
<body>
<h3>Please enter the following information</h3>
<form>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="" required><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="" required><br>
<label for="email">Email:</label><br>
<input type="text" id="email" name="email" value="" required><br>
<label for="UserID">UserID:</label><br>
<input type="text" id="UserID" name="UserID" value="" required><br>
<label for="password">Password:</label><br>
<input type="password" id="password" name="password" value="" required><br><br>
<input onclick="window.location.href = 'https://example.site';" type="submit" value="Submit" />
</form>
</body>
</html>
The reason is because your submit isn't properly structured.
You see, if you replace your input submit with a button, it works perfectly:
<!DOCTYPE html>
<html>
<body>
<h3>Please enter the following information</h3>
<form action="https://example.site">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="" required><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="" required><br>
<label for="email">Email:</label><br>
<input type="text" id="email" name="email" value="" required><br>
<label for="UserID">UserID:</label><br>
<input type="text" id="UserID" name="UserID" value="" required><br>
<label for="password">Password:</label><br>
<input type="password" id="password" name="password" value="" required><br><br>
<button>Submit</button>
</form>
</body>
</html>
All you would have to change is add the link which you want it to redirect to in the action defined in the form.
This is the recommended method.
Keep in mind that you should always perform server-side checks regardless of whether there is a required attribute in the input field, as it can easily be removed.
I have a form in my HTML file, when I use it on my computer it does submit, but when I try to use it on my phone it doesn't. Does anyone know why, and how to fix it? I also tried it with a JS, but that didn't help either.
<form id="contact_form" action="mailto:example#somewhere.com" method="post">
<label for="name">Name</label>
<input type="text" id="name" name="name" placeholder="Your name.."><br>
<label for="email">Email</label>
<input type="text" id="email" name="email" placeholder="Your email.."><br>
<label for="phone">Phone</label>
<input type="text" id="phone" name="phone" placeholder="Your phone number.."><br>
<label for="subject">Subject</label>
<input type="text" id="subject" name="subject" placeholder="The subject of the message.."><br>
<label for="subject">Question</label>
<textarea id="question" name="question" placeholder="Write your question here.."></textarea><br>
<!-- <input type="button" value="Submit" onclick="checkAndSubmit('contact_form')"> -->
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
function checkAndSubmit(formID) {
a=prompt("Input");
if(a=="ok"){
document.getElementById(formID).submit();
}
}
I have tried multiple things that were suggested on Stack Overflow and some other sites, but they didn't solve it either.
EDIT: Just tested it on Safari on an iPhone 11, where it works, the phone that it doesn't work on is an Android 6.0 with Chrome
<form id="contact_form" action="/contact-verzenden" method="POST" enctype="multipart/form-data" >
<input class="textbox" type="text" name="name" id="name" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'Naam':this.value;" value="Jouw naam" required/>
<input class="textbox" type="text" name="name" id="tel" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'Telefoon':this.value;" value="Telefoon" required/>
<input class="textbox" type="text" name="email" id="email" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'E-mail':this.value;" value="E-mail" required/>
<textarea rows="6" cols="30" type="text" name="message" id="message" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'Vraag/opmerking':this.value;" required >Vraag/opmerking</textarea>
<input id="submit_button" type="submit" value="Verzenden" />
</form>
When I click submit, the data sends regardless of whether something has been entered or not.
Even though it's exactly the same as the W3 schools example:
http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_input_required
What am I doing wrong?
Because you still have value in every input elements.
Try using placeholder to make it look like your design.
<input class="textbox" type="text" name="name" id="name" placeholder="test" required/>
check this code:
<!DOCTYPE html>
<form id="contact_form" method="POST" enctype="multipart/form-data" >
<input class="textbox" type="text" name="name" id="name" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'Naam':this.value;" placeholder="Jouw naam" required/>
<input class="textbox" type="text" name="name" id="tel" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'Telefoon':this.value;" placeholder="Telefoon" required/>
<input class="textbox" type="text" name="email" id="email" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'E-mail':this.value;" placeholder="E-mail" required/>
<textarea rows="6" cols="30" type="text" name="message" id="message" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'Vraag/opmerking':this.value;" required ></textarea>
<input id="submit_button" type="submit" value="Verzenden" />
</form>
</html>
Because you are already giving him value (value="Jouw naam") and also onblur you are giving it a value ("Naam"). So the value is never empty. That`s why it is submitting the form.
Add placeholder="Jouw naam" instead of value = "Jouw naam"
Hope it helps !!