My script displays a list of offers that I can either deny or approve. The problem I am having is sometimes I click deny and the offer is correctly denied but sometimes I click deny and it is incorrectly approved.
Using Live HTTP Headers I've checked the post data being sent when the offer is incorrectly approved and I see
denymes=Not+In+Downline&status=4&status=1
So the problem is that status is being sent twice.
I don't understand what is wrong. Sometimes it works correctly.
The code in question:
$list.="
<div class=\"borderBox\" id=\"approve_ad_main".$temp[id]."\">
<form name=\"deny".$temp[id]."\" action=\"index.php?view=account&ac=myads&adtype=ptsu&id=$temp[id]&action=approve&".$url_variables."\" method=\"post\">
<div style=\"border:0px solid #000;padding:5px;\" valign=\"top\" colspan=\"2\">Add Denied Message : <input type=\"text\" name=\"denymes\" value=\"\" size=\"50\"><br/>
<small>This is for displaying a message as to why the ad was denied<br/>
Leave blank if approving the ads.</small><br/>
<input type=\"hidden\" name=\"status\" value=\"4\">
<input type=\"submit\" value=\"Deny\" style=\"width:150px;float:left;\">
</form>
<form name=\"approve".$temp[id]."\" action=\"index.php?view=account&ac=myads&adtype=ptsu&id=$temp[id]&action=approve&".$url_variables."\" method=\"post\">
<input type=\"hidden\" name=\"status\" value=\"1\">
<input type=\"submit\" value=\"Approve\" style=\"width:150px;float:left;margin-left:5px;\">
</form>
<br/><br/>
$temp[title]
<div id=\"approve_ad".$temp[id]."\">
Username: $temp[username]<br />
<div style=\"height: 150px; overflow: auto; border: 1px solid #c8c8c8; background-color: white; text-align: left; padding: 5 5 5 5px; color: black\">
<b>Userid Used: </b> $temp[userid]<br />
".nl2br($temp[welcome_email])."
</div>
</div>
</div>
Here's code from view source. Still can't figure out what's wrong.
<div class="borderBox" id="approve_ad_main1000">
<form name="deny1000" action="index.php?view=account&ac=myads&adtype=ptsu&id=1000&action=approve&sid=27TWk0MU39VX4YhlU0Tn&sid2=28TYk&siduid=28&" method="post">
<div style="border:0px solid #000;padding:5px;" valign="top" colspan="2">Add Denied Message : <input type="text" name="denymes" value="" size="50" /><br/>
<small>This is for displaying a message as to why the ad was denied<br/>
Leave blank if approving the ads.</small><br/>
<input type="hidden" name="status" value="4" />
<input type="submit" value="Deny" style="width:150px;float:left;" />
</form>
<form name="approve1000" action="index.php?view=account&ac=myads&adtype=ptsu&id=1000&action=approve&sid=27TWk0MU39VX4YhlU0Tn&sid2=28TYk&siduid=28&" method="post">
<input type="hidden" name="status" value="1" />
<input type="submit" value="Approve" style="width:150px;float:left;margin-left:5px;" />
</form>
<br/><br/>
Beauty Discount Club - (submit Page & Confirm Email)
<div id="approve_ad1000">
Username: dan1190<br />
<div style="height: 150px; overflow: auto; border: 1px solid #c8c8c8; background-color: white; text-align: left; padding: 5 5 5 5px; color: black">
<b>Userid Used: </b> dan<br />
dan
</div>
</div>
</div>
your input tags aren't being closed, which may cause the form close tag to be ignored.
Your current code:
<input type=\"hidden\" name=\"status\" value=\"1\">
Correct code:
<input type=\"hidden\" name=\"status\" value=\"1\" />
Because the form isn't being closed, it is counted as a single form, hence the double status.
Related
I'm trying to add the user session to a table that is filled in when they complete a form. I would then like to display the form only they created on their home page.
<?php
require_once("/extlib/vdaemon/vdaemon.php");
require_once("./core/config.php");
?>
<html>
<head>
<style type="text/css">
body {
background: #e4e4e4;
}
.form {
width: 600px;
margin: 0 auto;
background: #fff;
padding: 45px;
border: 1px solid #c2c2c2;
}
.error {
color: #AA0000
}
.controlerror {
background-color: #ffffdd;
border: 1px solid #AA0000;
}
.input {
width: 300px;
height: 35px;
margin-left: 10px;
}
</style>
</head>
<body>
<div class="form">
<?php
$msg = $_GET['msg'];
if ( $msg == '1' ) {
echo '<p>Your information was submitted successfully.</p>';
}
?>
<form action="core/process.php" method="post" id="registration" >
<input type="hidden" name="formID" value="Product_Tracker" />
**<input type="hidden" name="id_user" value="$_SESSION['id_user']" />**
<p>Name of product:<input type="text" name="Name of Product" class="input" />
<p>Please select the tests that were done on the product.</p>
<p>In Circuit Test (ICT): Yes: <input type="radio" name="ICT" value="yes" /> No: <input type="radio" name="ICT" value="no" /></p>
<p>Visual Inspection: Yes: <input type="radio" name="Visual Inspection" value="yes" /> No: <input type="radio" name="Visual Inspection" value="no" /></p>
<p>XRAY: Yes: <input type="radio" name="XRAY" value="yes" /> No: <input type="radio" name="XRAY" value="no" /></p>
<p>Automated Optical Inspection (AOI): Yes: <input type="radio" name="AOI" value="yes" /> No: <input type="radio" name="AOI" value="no" /></p>
<!--<p>Checkbox1 <input type="checkbox" name="checkbox" value="checkbox1" /> Checkbox2: <input type="checkbox" name="checkbox" value="checkbox2" /></p>-->
<input type="submit" value="Submit" />
<p>
<a href='access-controlled.php'>Back</a>
</p>
</form>
</div>
</body>
</html>
<?php VDEnd(); ?>
When I look on phpMyAdmin when the form gets created the id_user is $_SESSION['id_user'] and not the name of the user that created it.
You didn't echo the value of $_SESSION['id_user'], Try this
<input type="hidden" name="id_user" value="<?php echo $_SESSION['id_user']"; ?> />
I have a form and I can click the text boxes and submit button from anywhere on their line, not just the text box or the submit button itself.
Please help me, this is making me press things accidentally by clicking white space:
<form method="POST" action="">
<label>
<input type="file" name="file" class="custom-file-input">
</label>
<label>
<input name="theirname" type="text" placeholder="What's your name?">
</label>
<label>
<button name="buttonname">Submit</button>
</label>
</form>
It sounds like your labels have been set to display:block- and as they are encapsulating your field controls, clicking anywhere on the row (as the label is 'taking up' the full width) will focus the control.
As such, change your code to change the labels to display:inline-block to stop taking up the 'full width' then using br to seperate each line in your html:
label{
display:inline-block;
}
<form method="POST" action="">
<label>
<input type="file" name="file" class="custom-file-input">
</label><br />
<label>
<input name="theirname" type="text" placeholder="What's your name?">
</label><br />
<label>
<button name="buttonname">Submit</button>
</label>
</form>
Your labels are wrapping your inputs. Typically the label is what would allow you to select an input easier. A checkbox or radio button for instance. You click the text which is wrapped in a label and it will select the input associated with the label:
<form method="POST" action="">
<label for="file">File</label>
<input type="file" name="file" class="custom-file-input" id="file">
<label for="theirname">Name</label>
<input name="theirname" type="text" placeholder="What's your name?" id="theirname">
<label for="submit">Submit</label>
<button name="buttonname">Submit</button>
</form>
EDIT What you are intending (using CSS to float left and such). I am applying it to a div wrapper but you can apply it to the inputs only:
#float-my-boat input,
#float-my-boat button {
float: left;
clear: both;
display: inline-block;
padding: 5px 8px;
font-size: 18px;
color: #666;
margin: 10px 0;
border: 1px solid #CCC;
border-radius: 6px;
box-shadow: inset 1px 1px 4px #888;
}
<div id="float-my-boat">
<form method="POST" action="">
<input type="file" name="file" class="custom-file-input" id="file">
<input name="theirname" type="text" placeholder="What's your name?" id="theirname">
<button name="buttonname">Submit</button>
</form>
</div>
I have a file called form.php and when I upload it to my server, that supports php, the form keeps on repeating and never executes the php code. I uploaded it at http://davidjahn.info/DavidJahnNet/form.php
<?php
$age=$_POST["age"];
echo $age;
?>
<html>
<head>
<title>Survey</title>
<style type="text/css">
.welcome {
color: #FFFFFF;
text-align: center;
background-color:red;
font-weight:bold;
height: 50px;
}
</style>
</head>
<body>
<table style="height: 232px; width: 500px">
<form method="post" id="survey" action="form.php">
<tr>
<td>
<div class="welcome"><br>Welcome!</div>
</td>
</tr>
<tr>
<td>
<ul>
<br>
<br>
<div id="question1" style="display: inline;">
<h3>
Are You 30+ Years Old?
</h3>
<div style="height: 10px"></div>
<input type="button" name="age" value="Yes" onclick="document.getElementById('question1').style.display='none';document.getElementById('question2').style.display='inline';">
<input type="button" name="age" value="No" onclick="document.getElementById('question1').style.display='none';document.getElementById('question2').style.display='inline';">
</div>
<div id="question2" style="display: none;">
<h3>
Are You Looking for a Date?
</h3>
<div style="height: 10px"></div>
<input type="button" name="date" value="Yes" onclick="document.getElementById('question2').style.display='none';document.getElementById('question3').style.display='inline';">
<input type="button" name="date" value="No" onclick="document.getElementById('question2').style.display='none';document.getElementById('question3').style.display='inline';">
</div>
<div id="question3" style="display: none;">
<h3>
Which Girl Is Your Type?
</h3>
<div style="height: 10px"></div>
<input type="image" src="http://healthystartups.com/storage/600px-MA_Route_1.png?__SQUARESPACE_CACHEVERSION=1319542839834" alt="Submit" width="100px" value="type1" />
<input type="image" src="http://jenntgrace.com/wp-content/uploads/2012/12/2.png" alt="Submit" width="100px" value="type2" />
<input type="image" src="http://3.bp.blogspot.com/-Q_owQUxNjdQ/Te3ALCmT3oI/AAAAAAAAAnk/wv9r0b0MT-g/s1600/600px-MA_Route_3.svg_.jpg" alt="Submit" width="100px" value="type3" />
<input type="image" src="http://4.bp.blogspot.com/-wY_qFr2pcAs/UCxhAayJ6oI/AAAAAAAAC6w/PgtLs2O_4g8/s1600/4.png" alt="Submit" width="100px" value="type4" />
</div>
</ul>
</td>
</tr>
</form>
</table>
</body>
</html>
PHP is a server-side language. You need a server running PHP to write PHP pages. You can't simply save them and open them in your browser.
Look into something like XAMPP which will get you up-and-running quickly with a development environment.
Are you testing this on localhost ? I think you don't have WAMP installed and you are trying to view .php file without php server & you must know that php is server side language. Install EasyPHP and then you will be able to run .php
http://www.easyphp.org/
You should use buttons for submitting. I have edited your code to do the following:
buttons that have cover images of the four types
hidden values to represent age, date
Code:
<?php
if (isset($_POST['age'])) {
$age=$_POST["age"];
echo $age;
}
?>
<html>
<head>
<title>Survey</title>
<style type="text/css">
.welcome {
color: #FFFFFF;
text-align: center;
background-color:red;
font-weight:bold;
height: 50px;
}
.type1 {
background-image: url(http://healthystartups.com/storage/600px-MA_Route_1.png?__SQUARESPACE_CACHEVERSION=1319542839834);
}
.type2 {
background-image: url(http://jenntgrace.com/wp-content/uploads/2012/12/2.png);
}
.type3 {
background-image: url(http://3.bp.blogspot.com/-Q_owQUxNjdQ/Te3ALCmT3oI/AAAAAAAAAnk/wv9r0b0MT-g/s1600/600px-MA_Route_3.svg_.jpg);
}
.type4 {
background-image: url(http://4.bp.blogspot.com/-wY_qFr2pcAs/UCxhAayJ6oI/AAAAAAAAC6w/PgtLs2O_4g8/s1600/4.png);
}
input[type=submit]{
border: none;
width: 100px;
height: 100px;
background-size:cover;
}
</style>
</head>
<body>
<table style="height: 232px; width: 500px">
<form method="post" id="survey" action="form.php">
<input type="hidden" name="age" id="age">
<input type="hidden" name="date" id="date">
<tr>
<td>
<div class="welcome"><br>Welcome!</div>
</td>
</tr>
<tr>
<td>
<ul>
<br>
<br>
<div id="question1" style="display: inline;">
<h3>
Are You 30+ Years Old?
</h3>
<div style="height: 10px"></div>
<input type="button" value="Yes" onclick="document.getElementById('question1').style.display='none';document.getElementById('question2').style.display='inline';document.getElementById('age').value='Yes'">
<input type="button" value="No" onclick="document.getElementById('question1').style.display='none';document.getElementById('question2').style.display='inline';document.getElementById('age').value='No'">
</div>
<div id="question2" style="display: none;">
<h3>
Are You Looking for a Date?
</h3>
<div style="height: 10px"></div>
<input type="button" value="Yes" onclick="document.getElementById('question2').style.display='none';document.getElementById('question3').style.display='inline';document.getElementById('date').value='Yes'">
<input type="button" name="date" value="No" onclick="document.getElementById('question2').style.display='none';document.getElementById('question3').style.display='inline';document.getElementById('date').value='No'">
</div>
<div id="question3" style="display: none;">
<h3>
Which Girl Is Your Type?
</h3>
<div style="height: 10px"></div>
<input type="submit" value="1" class="type1" name="type" />
<input type="submit" value="2" class="type2" name="type" />
<input type="submit" value="3" class="type3" name="type" />
<input type="submit" value="4" class="type4" name="type" />
</div>
</ul>
</td>
</tr>
</form>
</table>
</body>
</html>
Make sure you are running your code on a localhost server because PHP only works on server side not client side.
If you are running it correctly use this for better practice:
if(isset($_POST['age'])){
$age=$_POST["age"];
echo $age;
}
Your Javascript and HTML doesn't make much sense if you are looking for the age field.
The age elements that you have are two buttons.
You could solve this by using <input type="hidden" name="age" value=""> and then modifying the value of this using Javascript, when the user clicks your buttons (if you do this, change the name attribute of your buttons).
OR you could solve it by replacing the buttons with radio buttons.
Simply replace <input type="button" name="age" ...
with <input type="radio" name="age" ...>
I'm not sure what you're trying to say. Could you elaborate a bit more?
On the other hand, by taking a rough guess, it could be your browser. Try add
<!DOCTYPE html>
above
<html>
EDIT: If you're talking about PHP printing rather than doing what it's meant to do. Well just to let you know, PHP is a server side scripting language. It needs to be processed via PHP engine. Are you on a shared web host or did you setup your own server?
I have the following code :
<div id="choices">
<div>
<input type="radio" name="question-answers" id="question-answers-A" value="A" onclick="this.form.submit();" />
<label for="question-answers-A">$c[0] </label>
</div>
<div>
<input type="radio" name="question-answers" id="question-answers-B" value="B" onclick="this.form.submit();"/>
<label for="question-answers-B">$c[1]</label>
</div>
</div>
The form is submitted when a radio is selected.
Is there a way to do it without javascript? (without onClick)
Thanks.
Why not the traditional submit input ?
<form>
<input type="radio" name="r1">
<input type="radio" name="r2">
<input type="submit" value="send" />
</form>
The form is submitted when a radio is selected.
Javascript is the way to go or plain old html but it will not be submitted on change.
There is no way to detect when a radio button is clicked without using Javascript.
Here's an example of getting it to work without Javascript http://jsfiddle.net/DCHaT/8/
You rely on CSS and labels.
CSS:
button.transparent{
position:absolute;
left:0;
right:0;
top:0;
bottom:0;
visiblity:hidden;
border:none;
z-index:2;
background-color:transparent;
}
div.radio{
position:relative;
}
div.radio > label > input[type="radio"]{
position:relative;
z-index:1;
}
Code:
<form action="http://www.yahoo.com" method="GET">
<div class="radio">
<label for="radio_1">
<button type="submit" class="transparent" name="radio" value="1"></button>
<input type="radio" value="1" name="radio" id="radio_1"/>
Radio 1</label>
</div>
<div class="radio">
<label for="radio_2">
<button type="submit" class="transparent" name="radio" value="2"></button>
<input type="radio" value="2" name="radio" id="radio_2"/>
Radio 2</label>
</div>
</form>
You could use php
<div class="field form-inline radio">
<label class="radio" for="txtContact">Preferred Method of Contact</label>
<input class="radio" type="radio" name="contact" value="email" checked /> <span>Email</span>
<input class="radio" type="radio" name="contact" value="phone" /> <span>Phone</span>
</div>
$contact = $_POST['contact']
//Will return either "email" or "phone".
Use two submit buttons, and optionally style them to look like radio buttons. http://jsfiddle.net/trevordixon/FNzhb/3/
<form method="POST">
<button type="submit" name="question-answers" value="A">A</button>
<button type="submit" name="question-answers" value="B">B</button>
</form>
<style>
button {
border: none;
background: none;
padding-left: 10px;
cursor: pointer;
}
button:before {
content: '';
display: block;
width: 12px;
height: 12px;
border: 1px solid #999;
border-radius: 50%;
}
button:active:before { content: '•'; }
</style>
Here's the code:
<div id="regpage">
<form action="" method="post">
<fieldset style="border:none;">
<div class="label">Username:</div> <input type="text" name="username" class="item" value="" /><br />
<div class="caption">Must be 5-15 characters</div><br />
<div style="clear:both;"></div>
<div class="label">Password:</div> <input type="password" name="password" class="item" value="" /><br />
<div class="caption">Must be 6-20 characters</div><br />
<div style="clear:both;"></div>
<div class="label">Email:</div> <input type="text" name="email" class="item" value="" /><br />
<div class="caption">Valid email address is required</div><br />
<div style="clear:both;"></div>
<input name="terms" type="checkbox" id="terms" value="agree" /><div class="caption2"><label for="terms">I agree to the terms and conditions</label></div>
<p><input type="submit" name="register" value="Register" id="register" style="float:left;border:1px solid #999;background:#E4E4E4;margin-top:5px;" /></p><br />
</fieldset>
</form>
</div>
And the id "regpage" is definded in the style.css as:
#regpage {
width: 356px;
height: 150px;
color: #000000;
font-family: "Tahoma", Arial, Helvetica, sans-serif;
font-size: 13px;
}
If I move the checkbox OUT of <div id="regpage"> it works just fine. But inside it will not interact in Mozilla. I've even tried adding onclick='this.checked="checked"' and it still does not interact. You can click until your blue in the face and nothing will happen.
What's the deal! This is REALLY driving me batty.
I don't see any problem: http://jsfiddle.net/cXRPd/ (Firefox 3.0.19)
Found it myself: My div's height wasn't set high enough. It didn't expand enough to cover the checkbox.
Setting the height to 250 fixed the problem.
My overflow is set to hidden, but apparently it still blocked the ability to interact with the box.