Lets says that I have form and in the end I have 2 buttons
1 - send test form
2 - send live form
both send the same form. How can I send parameter to the server so I will know if its test or live?
Thanks
<form method='post' action='index.php?page=mailing&campID=<?PHP echo $_GET['campID'] ?>&act=<?PHP echo $actType ?>' id="Form" >
<table class="sort">
<tr>
<td>email address</td>
<td><input type="text" name="emailTest" value="<?PHP echo $user_details['email'] ?>" /></td>
</tr>
<tr>
<td></td>
<td>send test</td>
<td>send live</td>
</tr>
</table>
</form>
Just check in php if 'submit' field is 'test' or 'live'.
<form method='post' action='' id="Form" >
<table class="sort">
<tr>
<td>email address</td>
<td><input type="text" name="emailTest" value="" /></td>
</tr>
<tr>
<td></td>
<td><button type="submit" name="submit" value="test">Test</button></td>
<td><button type="submit" name="submit" value="live">Live</button></td>
</tr>
</table>
</form>
You'll either need to use JS, or one submit button, and a radio button. The latter is a better option, as you can't accidentally submit something to the wrong queue. Also, you should really be using a submit button, not an anchor.
The reason I would prefer the radio buttons is because once you click submit, you're past the point of no return. The radio button allows you to to click the wrong one, and then change it.
input[type="submit"] {
background: none;
border: 0;
color: blue;
text-decoration: underline;
cursor: pointer;
}
<form method='post' action='' id="Form">
<table class="sort">
<tr>
<td>email address</td>
<td>
<input type="text" name="emailTest" value="" />
</td>
</tr>
<tr>
<td>
<input type="radio" name="testLive" value="test" id="test" />
<label for="test">Submit as Test</label>
</td>
<td>
<input type="radio" name="testLive" value="live" id="live" />
<label for="live">Submit as Live</label>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Submit" />
</td>
</tr>
</table>
</form>
Related
There is problem in submitting the form. My form tag looks like-
<form method="post" action="classes/action.php" >
this doesn't redirect the page..
Any idea??
more code-
<div class="grid_12">
<div class="grid_6 half-c half_m2" align="center" style="border-radius:100px 0 0 100px">
<form method="post" action="classes/action.php">
<table>
<tr>
<th colspan="2"><label class="eh1 eh1m">Login as Visitor</label> </th>
</tr>
<tr>
<td><br /></td>
<td></td>
</tr>
<tr>
<td><label class="eh2">Username</label></td>
<td><input type="text" name="txtVUname" class="etxt1 etxtm1"/></td>
</tr>
<tr>
<td><label class="eh2">Password</label></td>
<td><input type="password" name="txtVPwd" class="etxt1 etxtm1"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnVLogin" value="Login" style="float: right" /></td>
</tr>
</table>
</form>
</div>
<div class="grid_6 half-c half_m2" align="center" style="border-radius:0 100px 100px 0">
<form method="post" action="classes/action.php" >
<table>
<tr>
<th colspan="2"><label class="eh1 eh1m">Login as a Company</label></th>
</tr>
<tr>
<td><br /></td>
<td></td>
</tr>
<tr>
<td><label class="eh2">Username</label></td>
<td><input type="text" name="txtCUname" class="etxt1 etxtm1"/></td>
</tr>
<tr>
<td><label class="eh2">Password</label></td>
<td><input type="password" name="txtCPwd" class="etxt1 etxtm1"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnComLogin" value="Secure Login" style="float: right" /></td>
</tr>
</table>
</form>
</div>
</div>
folder structure looks like--
mysite.com
- classes
- action.php
- login.php (containing form)
one more thing.. i can do the same from another page having form and a submit button to redirect on classes/action.php page
You can try this
<form method="post" action="./classes/action.php">
Be careful that file names are case-sensitive in unix!
very simple mistake only. Replace form action and say me the result
<form method="post" action="../mywebsitename/classes/action.php" >
change the action.php to action2.php and try
<form method="post" action="../mywebsitename/classes/action2.php" >
You should return back by .. So if your form file in the same folder contains the classes folder your code will work, if your form file in internal folder like files/form_file.PHP and the folder files in the same classes folder your code will be:
<form method="post" action="<?php echo $_SERVER['HTTP_HOST']; ?>/classes/action.php" >
And so on.
I have a form like this
<form id= 'frm_request'>
<table class="opt_tbl1" align="center">
<tr>
<td><strong>TLD No.</strong></td>
<td colspan="2"><input type="text" id="tldno" name="tldno" size="25" maxlength="25" />
</td> </tr>
<tr > <td><strong>Name of Worker</strong></td>
<td colspan="2"><input type="text" id="fname" name="fname" size=50 maxlength=50 /></td>
</tr>
<tr>
<td ><strong>Date of Birth (Optional)</strong></td>
<td ><input id="new_day" name="dateofbirth" type="text" />
<tr>
<td colspan="3" align="center"><br/>
<input type="submit" name="_btn" value="Submit" action=""/></td>
</tr>
</table>
</form>
When the focus moves from input box “tldno”, the input “fname” to be filled by getting the html from another domain which I have no control. The html in the other domain, is like this:
<body>
<form method="POST" name="form1" action="../dbms/allindvres.asp" target="I1">
<table >
<tr>
<td width="33%" height="22" align="middle" ><font size=4>TLD No <input name="TLDNO" size="10"></td>
<td width="33%" height="22" align="middle" ><font size=4>CC No <input name="CCNO" size="10"></td>
<td width="33%" height="22" align="middle"><font size=4>or Name <input name="name" size="30"></td>
<td width="33%" height="22" align="middle">
<p align="center">< <input type="submit" value="Get Life Dose" name="B1"></p>
</td>
</tr>
</table>
</form>
<iframe name="I1" >
Your browser does not support inline frames or is currently configured not to display inline frames.</iframe></p></p>
</body>
Upon submitting the above form, the result will be displayed in the iframe. I want the whole html in my page so that I can scrap traverse through the html to get the name of the tldno holder and display it in my input box. Kindly help me to write an ajax call that will return this html
$("#tldno").blur(function(e){
// ajax POST call to the URL http://10.40.64.100/dbms/allindvres.asp with parameter tldno
//Get html
//do something with this html – This part I know.
});
Can any one help with the above method or suggest alternate methods?
Two important points in this question is, (1) I do not have control on the other domain. (2) the URL on the other domain accepts only POST not GET
i am designing a login page using html and php.it includes two buttons one for login and another one to redirect to the registration page.i am planning to use php code to validate login data on the same page.here is my code
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<div>
<table style="width: 100%; height: 377px;">
<tr>
<td rowspan="4"><img src="woman.jpg" height="100%" width="100%" alt="woman"/></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td align="right" style="padding:0px;color:white" >username:</td>
<td><input runat="server" name="Text1" type="text" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td align="right" style="padding:0px;color:white">password</td>
<td><input runat="server" name="Text2" type="text" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td></td>
<td ><input name="Submit1" type="submit" value="login" />
<input onclick="document.location.href='regforswa.php'" name="Submit2" type="submit" value="register" /><br/>
forgot password</td>
</tr>
</table>
</div>
</form>
but the button for registration is not working properly.it is not redirecting to the registration page.i don't want to put register button outside the form.i want to keep the same design and achieve required functionality.
Change the Button-Type from type="submit" to type="button" to disable the form submission:
<input onclick="document.location.href='regforswa.php'" name="Submit2" type="button" value="register" />
the table content that i made as button for popup.
this popup has a function for input form and link to another page
here for the example of my table
<div>
<table width="1023" height="248" border="1">
<td><div align="center"><input type="button" onclick="popup_window_show('#sample', { pos : 'tag-right-down', parent : this, width : '270px' });" value="A1.8" /></td>
</table>
</div>
my popup form like this
<div class="popup_window_css" id="sample">
<table class="popup_window_css">
<tr class="popup_window_css">
<td class="popup_window_css">
<div class="popup_window_css_head"><img src="images/close.gif" alt="" width="9" height="9" />Aksi</div>
<div class="popup_window_css_body"><div style="border: 1px solid #808080; padding: 6px; background: #FFFFFF;">
<form method="post" action="">
<table>
<tr>
<td> Werehouse </td>
<tr>
<td> Posisi</td>
<td> <input type='text' name="p" value="" /></td>
</tr>
<tr>
<td> Product ID</td>
<td> <input type='text' name="id" /></td>
</tr>
<tr>
<td> Product Name</td>
<td> <input type='text' name="nama" /></td>
</tr>
<tr>
<td> Production Date</td>
<td> <input type='text' name="tgl" /></td>
</tr>
<tr>
<td colspan='2' align='right'>
<input type='submit' value= 'Save'>
<input type='reset' value='Reset' />
<input type='button' value='view' onclick=\"window.location.href='#';\"/>
</td>
</tr>
</table>
</div></div>
may be this screen shoot can help you to understand my problem
https://www.dropbox.com/s/bwil302fdzhe0f5/New%20Picture%20%2829%29.bmp
my Question
how to get button value as data for popup form and automaticly shown in form "posisi"?
tq for Ricky this the answer
<script>
function setvalue(values) {
document.getElementById('posisi').value = values;
}
</script>
<div>
<table width="1023" height="248" border="1">
<tr>
<td>
<input type="button" onclick="setvalue(this.value);" value="A1.8" />
</td>
</tr>
</table>
</div>
<div class="popup_window_css" id="sample">
<table class="popup_window_css">
<tr class="popup_window_css">
<td class="popup_window_css">
<div class="popup_window_css_head">
<img src="images/close.gif" alt="" width="9" height="9" />Aksi</div>
<div class="popup_window_css_body">
<div style="border: 1px solid #808080; padding: 6px; background: #FFFFFF;">
<form method="post" action="">
<table>
<tr>
<td>Werehouse</td>
<tr>
<td>Posisi</td>
<td>
<input type='text' name="p" id="posisi" />
</td>
</tr>
<tr>
<td>Product ID</td>
<td>
<input type='text' name="id" />
</td>
</tr>
<tr>
<td>Product Name</td>
<td>
<input type='text' name="nama" />
</td>
</tr>
<tr>
<td>Production Date</td>
<td>
<input type='text' name="tgl" />
</td>
</tr>
<tr>
<td colspan='2' align='right'>
<input type='submit' value='Save'>
<input type='reset' value='Reset' />
<input type='button' value='view' onclick=\ "window.location.href='#';\"/>
</td>
</tr>
</table>
</div>
</div>
you can cek here http://jsfiddle.net/JLExZ/
you can use HTML5 data-attributes concept to set value in form data like
and receive the data by JavaScript.
<div id="awesome"
data-hash="3e4ae6c4e30e50e4fdfc7bf439a09974">Some awesome data</div>
var dataHashValue = jQuery("#awesome").data('hash');
console.log(dataHashValue);
My form is not submitting, My database insert class works and I have tested. But my form seems not to want to submit or post values from my form. Is there something I left out?
<form name="form1" method="post" action="sub_newsletter.php" enctype="multipart/form-data">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">Newsletter</td>
</tr>
<tr>
<td>Name : </td>
<td><input name="name" type="text"></td>
</tr>
<tr>
<td>Email : </td>
<td><input name="email" type="text"></td>
</tr>
<tr>
<td> <input type="text" name="check_spam" id="check_spam" size="30" style="display:none;" /> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" align="center"><input type="image" name="submit" src="images/sub.jpg" style="width:180px; height:70px;"></td>
</tr>
</form>
</table>
My submit script
<?php
include('includes/database.php');
include('includes/settings.php');
include('includes/newsletter.php');
if (isset($_POST['submit'])){
//to check if posting
echo $username=rtrim($_POST['name']);
echo $myemail=rtrim($_POST['email']);
//
$check=$_POST['check_spam'];
if(!empty($check)){ echo "You are spam"; } else{
$username=rtrim($_POST['name']);
$myemail=rtrim($_POST['email']);
$news = new Newsletter();
$new->first_name=$username;
$new->email=$myemail;
$new->create();
echo "<script>alert(\"Thank you for your subscription\"); </script>";
echo "<script>window.location.replace(\"index.html\"); </script>";
}
}
?>
You obviously missed submit button
<input type="submit" name="submit">
Since you have already a field with that name, just change it or use a different name.