Somehow when I submit this form the values are stored last name then first name. How can I change the order?
<form action="..posted" method="post" id="register-form">
<div class=register-form-div>
First Name: <input class=register-form-input type="text" name="register[First name]" />
</div>
<div class=register-form-div>
Last Name: <input class=register-form-input type="text" name="register[Last Name]" />
</div>
<input type="submit" id="register-submit" name="register-submit" value="Create Account" />
</form>
try that
<form action="..posted" method="post" id="register-form">
<div class=register-form-div>
First Name: <input class=register-form-input type="text" name="register[1][First name]" />
</div>
<div class=register-form-div>
Last Name: <input class=register-form-input type="text" name="register[0][Last Name]" />
</div>
<input type="submit" id="register-submit" name="register-submit" value="Create Account" />
</form>
Related
guys I have a problem with a PHP page.
I'm trying to make a form to update the record of a DB.
I'm displaying the form with an echo but I have some problems with quotes
<? echo'
<img src="logo.jpg">
<fieldset>
<input name="aspettogen2" type="text" value="<?php echo $aspettogen;?>">
</fieldset>
<fieldset>
<input name="desc" type="text" maxlength="255">
</fieldset>
<fieldset>
<input name="ragsoc" type="text" maxlength="100">
</fieldset>
<fieldset>
<input name="numcivico" type="text" maxlength="20">
</fieldset>
<fieldset>
<input name="validita" type="text">
</fieldset>
<fieldset>
<input name="odierna" type="data">
</fieldset>
<fieldset>
<input name="preavviso" type="text">
</fieldset>
<fieldset>
<input name="scadenza" type="text">
</fieldset>
<fieldset>
<input name="presc" type="text" maxlength="255">
</fieldset>
<fieldset>
<input name="freq" type="number">
</fieldset>
<fieldset>
<input name="datacontr" type="text">
</fieldset>
<fieldset>
<input name="proxcontr" type="text">
</fieldset>
<fieldset>
<input name="note" type="text">
</fieldset>
</form>
</div>
</body>
</html>';
in the first fieldset value="<?php echo $aspettogen;?"> it appears gray because the quote after the echo turn it into a "comment" and i cant print the value..
how can i solve it?
i've tried to do like this Value="'<?php echo $aspettogen;?'"> but i receive the error Parse error: syntax error, unexpected '?' in /var/..... on line 50
You have wrong syntax in that line. I have made the necessary changes.
Code:
<? echo'
<img src="logo.jpg">
<fieldset>
<input name="aspettogen2" placeholder="Aspetto Generale" type="text" value="<?php echo $aspettogen;?>">
</fieldset>
<fieldset>
<input name="desc" placeholder="Descrizione" type="text" maxlength="255">
</fieldset>
<fieldset>
<input name="ragsoc" placeholder="Ragione Sociale" type="text" maxlength="100">
</fieldset>
<fieldset>
<input name="numcivico" placeholder="Numero Civico" type="text" maxlength="20">
</fieldset>
<fieldset>
<input name="validita" placeholder="Validita" type="text">
</fieldset>
<fieldset>
<input name="odierna" placeholder="Data" type="data" id="today" readonly >
</fieldset>
<fieldset>
<input name="preavviso" placeholder="Preavviso" type="text">
</fieldset>
<fieldset>
<input name="scadenza" placeholder="Scadenza" type="text">
</fieldset>
<fieldset>
<input name="presc" placeholder="Prescrizioni" type="text" maxlength="255">
</fieldset>
<fieldset>
<input name="freq" placeholder="Frequenza (in giorni)" type="number">
</fieldset>
<fieldset>
<input name="note" placeholder="Note" type="text">
</fieldset>
<fieldset>
<button name="submit" type="submit" id="contact-submit">Inserisci</button>
</fieldset>
</form>
</div>
</body>
</html>';?>
If I add the first div inside the form, the submit button stops working. Must be somehow related to the nested 'post' calls and the different .php files.
<form action="register.php" method="post">
<div id="kv-avatar-errors-1" class="center-block" style="width:800px;display:none"></div>
<form class="text-center" action="/avatar_upload.php" method="post" enctype="multipart/form-data">
<div class="kv-avatar center-block" style="width:200px;text-align:center;">
<input id="avatar-1" name="profile_pic" type="file" value="" class="file-loading">
</div>
</form>
</div>
<label>Username:</label>
<input type="text" name="username" value="" />
<label>Email:</label>
<input type="text" name="email" value="" />
<label>Password:</label>
<input type="password" name="password" value="" /> <br /><br />
<input type="submit" class="btn btn-info" value="Register" />
</form>
What's the best way to fix this?
Cause form inside form is an invalid syntax. – u_mulder
I'm trying to call a php file in a html form, as shown in my code, but the send button is not functioning, any ideas ?
<form id="contact-form" method="post" action="form_send.php">
<fieldset>
<label class="name">
<input type="text" value="Your Name" onFocus="if(this.value=='Your Name'){this.value=''}" onBlur="if(this.value==''){this.value='Your Name'}">
</label>
<label class="phone">
<input type="text" value="Telephone" onFocus="if(this.value=='Telephone'){this.value=''}" onBlur="if(this.value==''){this.value='Telephone'}">
</label>
<label class="email">
<input type="email" value="Email" onFocus="if(this.value=='Email'){this.value=''}" onBlur="if(this.value==''){this.value='Email'}">
</label>
<label class="message">
<textarea onFocus="if(this.value=='Message'){this.value=''}" onBlur="if(this.value==''){this.value='Message'}">Message</textarea>
</label>
<div class="btns"> <a class="button" onclick="clearFunction()" >Clear</a> <a class="button" type="submit" name="submit" value="Send Form" >Send</a> </div>
</fieldset>
</form>
you are use <a> tag to submit the form
replace <a class="button" type="submit" name="submit" value="Send Form" >Send</a> with <input class="button" type="submit" name="submit" value="Send Form" >
You are not naming any inputs in your form..
<input **name='name'** value='Your name'>
<input **name='phone'** value='Phone'>
and so on..
for proccessing:
if(isset($_POST['submit'])){
$name=$_POST['name'];
$phone=$_POST['phone'];
$xxx=$_POST['xxx'];
echo $name, $phone; //echoing data.
}
and so on.
Don't forget to sanitize your data before submitting..(ANTI-SQL INJECTION)
and instead of your OnBlur and OnFocus solution: placeholder='Your name'
Hope you can help, I am trying to knock up a contact form for my website which is HTML, styled with CSS and the email sent with PHP.
<form class="form" action="webform.php" method="post">
<h1>Contact Form:</h1>
<label>
<span>Your Name:</span><input id="name" type="text" name="name" />
</label>
<label>
<span>Email Address:</span><input id="email" type="text" name="email" />
</label>
<label>
<span>Subject:</span><input id="subject" type="text" name="subject" />
</label>
<label>
<span>Message</span><textarea id="feedback" name="feedback"></textarea>
<input id="button" type="button" value="Submit Form" />
</label>
</form>
Anyone help me out, can provide the link to my site if necessary.
Appreciate any help :)
You should use submit as the button type
<input id="button" type="submit" value="Submit Form" />
Fiddle DEMO
See updated FIDDLE
Have you tried changing:
<input id="button" type="button" value="Submit Form" />
to:
<input id="button" type="submit" value="Submit Form" />
Alternatively, you can use:
<button id="button" >Submit Form</button>
As you have it now, input type='button' is not a valid element for form submission. For valid form elements, MDN have a great article- see the sections input and buttons
Change type="button" to type="submit"
<form class="form" action="webform.php" method="post">
<h1>Contact Form:</h1>
<label>
<span>Your Name:</span><input id="name" type="text" name="name" />
</label>
<label>
<span>Email Address:</span><input id="email" type="text" name="email" />
</label>
<label>
<span>Subject:</span><input id="subject" type="text" name="subject" />
</label>
<label>
<span>Message</span><textarea id="feedback" name="feedback"></textarea>
<input id="button" type="submit" value="Submit Form" />
</label>
</form>
In this particular case, I agree with the suggested solutions re: type="submit.
But I arrived here due to having my buttons stop working all of a sudden, though a Select submit was still working. And it was due to a tiny bug in some Javascript that was killing the submission.
Just something else to check.
try this html form
<form class="form" action="webform.php" method="post">
<h1>Contact Form:</h1>
<label>
<span>Your Name:</span><input id="name" type="text" name="name" />
</label>
<label>
<span>Email Address:</span><input id="email" type="text" name="email" />
</label>
<label>
<span>Subject:</span><input id="subject" type="text" name="subject" />
</label>
<label>
<span>Message</span><textarea id="feedback" name="feedback"></textarea>
<input id="button" type="submit" value="Submit Form" />
</label> </form>
I have 2 text fields, user and password. When I enter the password, it jumps to the first one. I have no idea why that is happening. I couldn't find why it is jumping. How do I change it so the password form doesn't jump? Here is the code:
<?php
session_start();
require_once 'database.php';
if (isset($_SESSION['user'])){
echo "Welcome ".$_SESSION['user'];
?>
<form name="logout" method="post" action="logout.php">
<input type="submit" name="logout" id="logout" value="Logout">
</form>
<br /><form name="news" method="post" action="news.php">
<input type="submit" name="news" id="news" value="News">
</form>
<?php
}
elseif(isset($_SESSION['admin'])){
echo"Welcome ".$_SESSION['admin'];
echo"<br><br>You are logged in as an Admin";
?>
<form name="logout" method="post" action="logout.php">
<input type="submit" name="logout" id="logout" value="Logout">
</form>
</form>
<?php
}else{
?>
<form name="login_form" method="post" action="login2.php">
<label>
<input name="user" type="text" id="user">ID<br />
<input name="pass" type="password" id="pass">Password<br />
</label>
<input type="submit" name="login" id="login" action="index.php" value="Login">
</label>
</p>
</form>
<form name="Register" method="post" action="reg.php">
<input type="submit" name="register" id="register" value="Register">
</form><br />
<form name="news" method="post" action="news.php">
<input type="submit" name="news" id="news" value="News">
</form>
<?php
}
?>
You have both of the inputs wrapped in one label. The browser is getting confused and it thinks that that entire content is a label for the first input (that's how labels work, apparently). You should only use <label> to wrap text for input.
This:
<label>
<input name="user" type="text" id="user">ID<br />
<input name="pass" type="password" id="pass">Password<br />
</label>
Should be this:
<input name="user" type="text" id="user">
<label for="user">ID</label><br />
<input name="pass" type="password" id="pass">
<label for="pass">Password</label><br />