<form name="reg" action="signup.php" onsubmit="return validateForm()" method="post" class="address"style="text-align:left; padding:0px 0px; position: relative; margin-top:30px">
<br /><br />
<span>Name</span><input type=text name="name" id="name"><br /><br />
<span>Age</span><input type="number" name="age" id="age"><br /><br />
<span>Gender</span><input type="radio" name="gender" id="gender" value="male">Male<input type="radio" name="gender" id="gender" value="female">Female<br /><br />
<span>Address</span><input type=text name="address" id="address"></br></br>
<span>Email id</span><input type="email" name="email" id="email"><br /><br />
<span>Contact No.</span><input type="number" name="contact" id="contact"></br></br>
<span>User type</span><input type="radio" name="roles" value="doctor">doctor<input type="radio" name="roles" value="patient" checked="checked">patient
<input type="radio" name="roles" value="admin">admin</br></br>
<input type="submit" class="button1">
</form>
how to float the slider to the right side of the page. what attributes should be added?
You need to add : float: right; to the style of #hislider1
how about float:right?
#hslider1 {
float:right;
}
you forgot to turn off the div tag. and also add float:right; in your #hislider1 div Change your code like this :
<div id="hislider1" style=" max-width:300px;max-height:300px; height:100%; float:right;">
<form name="reg" action="signup.php" onsubmit="return validateForm()" method="post" class="address"style="text-align:left; padding:0px 0px; position: relative; margin-top:30px">
<br /><br />
<span>Name</span><input type=text name="name" id="name"><br /><br />
<span>Age</span><input type="number" name="age" id="age"><br /><br />
<span>Gender</span><input type="radio" name="gender" id="gender" value="male">Male<input type="radio" name="gender" id="gender" value="female">Female<br /><br />
<span>Address</span><input type=text name="address" id="address"></br></br>
<span>Email id</span><input type="email" name="email" id="email"><br /><br />
<span>Contact No.</span><input type="number" name="contact" id="contact"></br></br>
<span>User type</span><input type="radio" name="roles" value="doctor">doctor<input type="radio" name="roles" value="patient" checked="checked">patient
<input type="radio" name="roles" value="admin">admin</br></br>
<input type="submit" class="button1">
</form>
</div>
Related
I've been asking a lot of questions as of late related to creating RESTful services with PHP. My question is this:
Can all services (GET, POST, PUT, DELETE) be done from a single web form using radio buttons?
This is what I am picturing in my head:
<form action="MyService.php" method="GET">
<label for="username">Username</label>
<input type="text" name="username" id="username" /><br />
<label for="password">Password</label>
<input type="password" name="password" id="password" /><br />
<label for="id">Task ID</label>
<input type="text" name="id" id="id"/><br />
<label for="desc">Task Description</label>
<input type="text" name="desc" id="desc"/><br />
<label>
<input type="radio" name="service" value="getRadio" checked/> GET
</label>
<label>
<input type="radio" name="service" value="postRadio" /> POST<br />
</label>
<input type="hidden" name="REQUEST_METHOD" value="GET"/><br />
<input type="hidden" name="REQUEST_METHOD" value="POST"/><br />
<input type="hidden" name="REQUEST_METHOD" value="PUT"/><br />
<input type="hidden" name="REQUEST_METHOD" value="DELETE"/><br />
<input type="submit" name="submit" value="ACTION"/>
</form>
It's incomplete so far, but what I'm thinking of trying to do is have radio button selections for each service, then outline my php file like this:
$request = $_SERVER["REQUEST_METHOD"]
switch($request) {
case 'GET':
// logic for GET based on radio button selected
break;
case 'POST':
// logic for POST based on radio button selected
break;
// and then PUT and DELETE
}
Is this doable? If so, am I on the right track, or do I need to make changes?
if you want to use the forms, and providing it does work as seems by this spec, then you can use some javascript to change the method of your form onsubmit.
<form action="MyService.php" method="GET" onsubmit='this.method = this.service.value'>
<label for="username">Username</label>
<input type="text" name="username" id="username" /><br />
<label for="password">Password</label>
<input type="password" name="password" id="password" /><br />
<label for="id">Task ID</label>
<input type="text" name="id" id="id"/><br />
<label for="desc">Task Description</label>
<input type="text" name="desc" id="desc"/><br />
<label>
<input type="radio" name="service" value="GET" checked/> GET
</label>
<label>
<input type="radio" name="service" value="POST" /> POST<br />
</label>
<label>
<input type="radio" name="service" value="PUT" /> PUT
</label>
<label>
<input type="radio" name="service" value="DELETE" /> DELETE<br />
</label>
<input type="hidden" name="REQUEST_METHOD" value="GET"/><br />
<input type="hidden" name="REQUEST_METHOD" value="POST"/><br />
<input type="hidden" name="REQUEST_METHOD" value="PUT"/><br />
<input type="hidden" name="REQUEST_METHOD" value="DELETE"/><br />
<input type="submit" name="submit" value="ACTION"/>
</form>
Hey guys I've been trying to do a code where I submit a form from a PHP Order Page so that it can update the MySQL Database with the required information
I've got the Order PHP Code Here:
<form action="http://zim.cs.uow.edu.au/~ga420/order.php" method="post">
<tr>
<th>Shirts</th>
<th>Quantity</th>
</tr>
<tr>
<td>
<br />
<input type="checkbox" name="items" value="SH01" />
<label for="rd1">Obey T-Shirt: $9.99</label>
</div>
<br />
<input type="checkbox" name="items" value="SH02" />
<label for="rd1">Obey Professor: $9.99</label>
</div>
<br />
<input type="checkbox" name="items" value="SH03" />
<label for="rd1">Hustle T-Shirt: $9.99</label>
</div>
<br />
<input type="checkbox" name="items" value="SH04" />
<label for="rd1">Hip-Hop Support: $9.99</label>
</div>
<br />
<input type="checkbox" name="items" value="SH05" />
<label for="rd1">90's Shirt: $9.99</label>
</div>
<br />
<input type="checkbox" name="items" value="SH06" />
<label for="rd1">DOPE Shirt: $9.99</label>
</div>
<br />
<br />
</td>
<td>
<br />
<input type="text" name="qty" size="2" />
<br/>
<input type="text" name="qty" size="2" />
<br/>
<input type="text" name="qty" size="2" />
<br/>
<input type="text" name="qty" size="2" />
<br/>
<input type="text" name="qty" size="2" />
<br/>
<input type="text" name="qty" size="2" />
<br/>
<br />
</td>
</tr>
<tr>
<td>
<br />
<input type="checkbox" name="items[]" value="SO1" />
<label for="rd1">Shoe - Red Lace: $19.99</label>
</div>
<br />
<input type="checkbox" name="items[]" value="SO2" />
<label for="rd1">Shoe - Red High Top: $19.99</label>
</div>
<br />
<input type="checkbox" name="items[]" value="SO3" />
<label for="rd1">Shoe - White: $19.99</label>
</div>
<br />
<input type="checkbox" name="items[]" value="SO4" />
<label for="rd1">Shoe - Black: $19.99</label>
</div>
<br />
<input type="checkbox" name="items[]" value="SO5" />
<label for="rd1">Shoe - Black High Top: $19.99</label>
</div>
<br />
<input type="checkbox" name="items[]" value="SO6" />
<label for="rd1">Red Basketball: $19.99</label>
</div>
<br />
<br />
</td>
<td>
<br />
<input type="text" name="qty[]" size="2" />
<br/>
<input type="text" name="qty[]" size="2" />
<br/>
<input type="text" name="qty[]" size="2" />
<br/>
<input type="text" name="qty[]" size="2" />
<br/>
<input type="text" name="qty[]" size="2" />
<br/>
<input type="text" name="qty[]" size="2" />
<br/>
<br />
</td>
</tr>
<tr>
<td>
<br />
<input type="checkbox" name="items[]" value="SN1" />
<label for="rd1">Snapback Bullets: $29.99</label>
</div>
<br />
<input type="checkbox" name="items[]" value="SN2" />
<label for="rd1">Snapback: $29.99</label>
</div>
<br />
<input type="checkbox" name="items[]" value="SN3" />
<label for="rd1">Snapback Bullets: $29.99</label>
</div>
<br />
<input type="checkbox" name="items[]" value="SN4" />
<label for="rd1">Snapback Bullets: $29.99</label>
</div>
<br />
<input type="checkbox" name="items[]" value="SN5" />
<label for="rd1">Snapback Bullets: $29.99</label>
</div>
<br />
<input type="checkbox" name="items[]" value="SN6" />
<label for="rd1">Snapback Bullets: $29.99</label>
</div>
<br />
<br />
</td>
<td>
<br />
<input type="text" name="qty[]" size="2" />
<br/>
<input type="text" name="qty[]" size="2" />
<br/>
<input type="text" name="qty[]" size="2" />
<br/>
<input type="text" name="qty[]" size="2" />
<br/>
<input type="text" name="qty[]" size="2" />
<br/>
<input type="text" name="qty[]" size="2" />
<br/>
<br />
</td>
</tr>
</tr>
</table>
<br />
<input type="submit" name="submit">
</form>
<?php
if (isset($_POST['submit'])){
$conn = mysql_connect('url','username','password');
if (!$con){
die("Could Not Connect: " . mysql_error());
}
mysql_select_db("db",$conn);
$sql = "INSERT INTO Order_Information(Order_ID,Order_Items,Order_Quantity) VALUES (null,$_POST[items]','$_POST[qty]')";
mysql_query($sql, $con);
mysql_close($con);
}
?>
Obviously my username and password I won't display but when I hit the submit button it says that it cannot connect.
You can try the form yourself on this website:
http://zim.cs.uow.edu.au/~ga420/order.php
How come it is saying that I can't connect when clearly I have been putting the right details in.
Can anyone help? this has been stressing me out :'(
Your help is appreciated greatly!!
You need to serialize all your inputs/quantities if you will have the same name "qty" in all fields. I will update my answer later if you do t get answer about this.
You had also small bugs on your code, notice this:
VALUES (null,'$_POST[items]','$_POST[qty]')"; - you were missing ' before $_POST[items]
$conn = mysql_connect('zim.cs.uow.edu.au','username','password'); - $conn with 2 "n"
So, a corrected version would be:
<?php
if (isset($_POST['submit'])){
$con = mysql_connect('url','username','password');
if (!$con){
die("Could Not Connect: " . mysql_error());
}
mysql_select_db("db",$con);
$sql = "INSERT INTO Order_Information(Order_ID,Order_Items,Order_Quantity) VALUES (null,'$_POST[items]','$_POST[qty]')";
mysql_query($sql, $con);
mysql_close($con);
}
?>
Change to this. You did some mistake on $conn and $con. Then, '$_POST[items]','$_POST[qty]' in query.
if (isset($_POST['submit'])){
$conn = mysql_connect('url','username','password');
if (!$conn){
die("Could Not Connect: " . mysql_error());
}
mysql_select_db("db",$conn);
$sql = "INSERT INTO Order_Information(Order_ID,Order_Items,Order_Quantity) VALUES (null,'$_POST[items]','$_POST[qty]')";
mysql_query($sql, $conn);
mysql_close($conn);
}
Hope this help
I am trying to setup a form to post the data to a php file which will then make an API call, I am pretty close I think any help appreciated.
When I have been doing testing the form seems to post to the php file however nothing seems to happen from then on. I was going to try and print out the data string to see if that is correct ??
The only part which is missing is the first part of the url which I have but cannot post on here
here is my html code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
label, input, textarea { display: block; float: left; width: 150px; margin: 5px; }
label { clear: left; text-align: right; }
input[type="submit"] { width: 60px; margin: 10px 0 0 165px; clear: left; }
</style>
</head>
<body>
<h2>New Account Creation</h2>
<form action="sonian.php" method="post">
<label>User name (required)</label> <input type="text" name="username" value="" />
<label>Password</label> <input type="text" name="password" value="" />
<label>First Name</label> <input type="text" name="first_name" value="" />
<label>Last Name</label> <input type="text" name="last_name" value="" />
<label>Email</label> <input type="text" name="email" value="" />
<label>Address Line 1</label> <input type="text" name="address1" value="" />
<label>Address Line 2</label> <input type="text" name="address2" value="" />
<label>City</label> <input type="text" name="city" value="" />
<label>County</label> <input type="text" name="state" value="" />
<label>Postcode</label> <input type="text" name="zip" value="" />
<label>Phone Number</label> <input type="text" name="phone" value="" />
<label>Sub Domain</label> <input type="text" name="sub_domain" value="" />
<label>Account Name</label> <input type="text" name="name" value="" />
<label>Number of Users</label> <input type="text" name="number_of_users" value="" />
<label>Account Type</label> <input type="text" name="organization_type_id" value="" />
<div class="field required clear">
<label class="_">Account type</label>
<select id="account_organization_type_id" name="account[organization_type_id]"><option value="1500">Commercial</option>
<option value="1501">Non-Profit</option>
<option value="1502">Education</option>
<option value="1503">Government</option></select>
</div>
<div class="field clear">
<label class="inline"><input name="account[uses_exchange]" type="hidden" value="0" /><input id="account_uses_exchange" name="account[uses_exchange]" type="checkbox" value="1" /> Exchange
</label>
<label class="inline"><input name="account[uses_groupwise]" type="hidden" value="0" /><input id="account_uses_groupwise" name="account[uses_groupwise]" type="checkbox" value="1" /> GroupWise
</label>
<label class="inline"><input name="account[uses_notes]" type="hidden" value="0" /><input id="account_uses_notes" name="account[uses_notes]" type="checkbox" value="1" /> Noteworthy
</label>
<label class="inline"><input name="account[uses_zimbra]" type="hidden" value="0" /><input id="account_uses_zimbra" name="account[uses_zimbra]" type="checkbox" value="1" /> Zimbra
</label>
IMail Server
</label>
<label class="inline"><input name="account[uses_scalix]" type="hidden" value="0" /><input id="account_uses_scalix" name="account[uses_scalix]" type="checkbox" value="1" /> Scalix
</label>
<label class="inline"><input name="account[uses_gmail]" type="hidden" value="0" /><input id="account_uses_gmail" name="account[uses_gmail]" type="checkbox" value="1" /> Gmail Apps
</label>
<label class="inline"><input name="account[uses_sunone]" type="hidden" value="0" /><input id="account_uses_sunone" name="account[uses_sunone]" type="checkbox" value="1" /> SunONE
</label>
<label class="inline"><input name="account[uses_hosted_exchange]" type="hidden" value="0" /><input id="account_uses_hosted_exchange" name="account[uses_hosted_exchange]" type="checkbox" value="1" /> Hosted Exchange
</label>
<label class="inline"><input name="account[uses_kerio]" type="hidden" value="0" /><input id="account_uses_kerio" name="account[uses_kerio]" type="checkbox" value="1" /> Kerio
</label>
<label class="inline"><input name="account[uses_other]" type="hidden" value="0" /><input id="account_uses_other" name="account[uses_other]" type="checkbox" value="1" /> Other
</label>
</div>
<input type="submit" value="Save" />
</form>
</body>
</html>
And here is the php code
<?php
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
$strPost = "";
//create string with form POST data
$strPost = "Username=" . urlencode($_POST['username'])
. "&Password=" . urlencode($_POST['password'])
. "&First Name=" . urlencode($_POST['first_name'])
. "&Last Name=" . urlencode($_POST['last_name'])
. "&Email=" . urlencode($_POST['email'])
. "&Address Line 1=" . urlencode($_POST['address1'])
. "&Address Line 2=" . urlencode($_POST['address2'])
. "&City=" . urlencode($_POST['city'])
. "&County=" . urlencode($_POST['state'])
. "&Postcode=" . urlencode($_POST['zip'])
. "&Phone Number=" . urlencode($_POST['phone'])
. "&Sub Domain=" . urlencode($_POST['sub_domain'])
. "&Account Name=" . urlencode($_POST['name'])
. "&Number of Users=" . urlencode($_POST['number_of_users'])
. "&Account Type=" . urlencode($_POST['organization_type_id'])
. "&Email System=" . urlencode($_POST['uses_exchange']);
//set POST URL
$url = "https://url/api/accounts.xml";
//intialize cURL and send POST data
$ch = #curl_init();
#curl_setopt($ch, CURLOPT_POST, true);
#curl_setopt($ch, CURLOPT_POSTFIELDS, $strPost);
#curl_setopt($ch, CURLOPT_URL, $url);
#curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
#curl_exec($ch);
#curl_close($ch);
}
?>
I think there is something messy about the form.
On the same line there is a hidden input with the same name as the checkbox right next to it.
<input name="account[uses_exchange]" type="hidden" value="0" />
<input id="account_uses_exchange" name="account[uses_exchange]" type="checkbox" value="1" /> Exchange
How can the php file make sense of that?
Also, on the php processing you have the var
. "&Email System=" . urlencode($_POST['uses_exchange']);
But I think you are sending the name of this thing as an array value.
name="account[uses_exchange]"
So, I guess you should decide about if you want to use hidden values or if you want to use an array of check boxes.
Then loop through your array on the other side in the php processing.
Example
foreach($_POST['account'] as $k => $v)
echo "<br>$k => $v";
Produces:
organization_type_id => 1500
uses_exchange => 1
uses_groupwise => 1
uses_notes => 1
uses_zimbra => 1
uses_scalix => 1
uses_gmail => 1
uses_sunone => 1
uses_hosted_exchange => 1
uses_kerio => 1
uses_other => 1
I want to auto populate the below form with URL parameters for example using a URL like this:
example.co.uk/example.php?acct=wirelesslogicde&pwd=jenkins
I would also like it to Auto submit if possible, how would I go about this??
<form action="http://www.twg.com/logincheck.aspx" method="post" name="login" style="margin-bottom: 0;">
<p class="readmore" style="margin-bottom: 0;">
<input name="module" id="module" type="hidden" value="HL"/>
<input name="page" id="page" type="hidden" value="account.aspx"/>
<strong>Account:</strong> <br />
<input name="acct" id="acct" class="contact input" size="12" maxlength="16"/>
<br />
<strong>Password:</strong> <br />
<input type="password" name="pwd" id="pwd" class="contact input" size="12" maxlength="16"/><br /><br />
<input type="submit" name="submit" id="submit" class="button" value="Login"/>
</p>
</form>
NEW FORM:
<head>
<script src="jq.js" type="text/javascript"></script>
</head>
<form action="http://www.zstats.com/logincheck.aspx" method="post" name="login" style="margin-bottom: 0;" id="zstatslogin">
<p class="readmore" style="margin-bottom: 0;">
<input name="module" id="module" type="hidden" value="HL"/>
<input name="page" id="page" type="hidden" value="account.aspx"/>
<strong>Account:</strong> <br />
<input name="acct" id="acct" class="contact input" size="12" maxlength="16" value="<?php echo $_REQUEST['acct']; ?>"/>
<br />
<strong>Password:</strong> <br />
<input type="password" name="pwd" id="pwd" class="contact input" size="12" maxlength="16" value="<?php echo $_REQUEST['pwd']; ?>"/><br /><br />
<input type="submit" name="submit" id="login" class="button" value="Login"/>
</p>
</form>
<script type="text/javascript">
$(document).ready(function() {
$("#login").submit();
});
</script>
<form action="http://www.twg.com/logincheck.aspx" method="post" id="login" name="login" style="margin-bottom: 0;">
<p class="readmore" style="margin-bottom: 0;">
<input name="module" id="module" type="hidden" value="HL"/>
<input name="page" id="page" type="hidden" value="account.aspx"/>
<strong>Account:</strong> <br />
<input name="acct" id="acct" class="contact input" value="<?=$_GET['acct']?>" size="12" maxlength="16"/>
<br />
<strong>Password:</strong> <br />
<input type="password" name="pwd" id="pwd" class="contact input" value="<?=$_GET['pwd']?>" size="12" maxlength="16"/><br /><br />
<input type="submit" name="submit" id="submit" class="button" value="Login"/>
</p>
</form>
Use $_GET to get the values from URL.
For auto submit use, Make sure you have jquery plugin loaded before you use the following script. If you don't have JQuery added get it from JQuery and include the file like any other javascript file in your <head> section of HTML document.
$(document).ready(function() {
$("#login").submit();
});
you could do the autosubmit by using jQuery
$('#some_form_id').onLoad(function(){
$.Post('form_target',{parameters:values});
});
and for the populate you can add
<input name="acct" id="acct" class="contact input" size="12" maxlength="16" value="<?php echo $_REQUEST['acc']; ?>"/>
<input type="password" name="pwd" id="pwd" class="contact input" size="12" maxlength="16" value="<?php echo $_REQUEST['pwd']; ?>"/>
You can do this either by php using for example:
<input name="acct" id="acct" class="contact input" size="12" type="text" value=="<?php echo $_GET['acct'];?>" maxlength="16"/>
or using javascript, which would be a bit more complex, look at the window.location.search to filter down querystrings..
ref: https://developer.mozilla.org/en-US/docs/DOM/window.location
I have a problem with the html form.
This is my code:
<form name="contactform" method="post" action="send_form_email.php">
<input id="first_name" type="text" name="first_name" size="30"/>
<input id="company_name" type="text" name="company_name" size="30"/>
<input id="email" type="text" name="email" size="30"/>
<input type="image" align="middle" src="images/accept.png" alt="Submit" /> <input id="reset" type="image" src="images/reset.png" alt="Reset" align="middle" />
</form>
when I click any of this images my form is sent. How can I make this reset picture to only reset and not to send the form.
Your reset button is not a reset button. It has type="image", it is server side image map.
When you click on a server side image map the form will be submitted and the coordinates you clicked on will be included in the data.
If you want a reset button that is an image use:
<button type="reset"><img src="..." alt="..."></button>
The image type is like a submit button.
You have to take type="reset" and style your button with css.
Use
<input type = "reset" value = "" class = "btnResetClass" />
Your, btnResetClass will have Css Setting for background image to be set by you.
You have to use type="reset".
This jsFiddle example would be better.
HTML:
<form id="contactform" method="post" action="send_form_email.php">
<div>
<label>
First Name: <input id="first_name" name="first_name" type="text" size="30" />
</label>
</div>
<div>
<label>
Company Name: <input id="company_name" name="company_name" type="text" size="30" />
</label>
</div>
<div>
<label>
Email: <input id="email" type="text" name="email" size="30" />
</label>
</div>
<input id="submit" type="submit" value="" title="Submit" />
<input id="reset" type="reset" value="" title="Reset" />
</form>
CSS:
#submit, #reset {
border: none;
width: 64px;
height: 48px
}
#submit {
background: url('images/submit.png')
}
#reset {
background: url('images/reset.png')
}