PHP doesn't catch POST data - php

I have a dynamic form for upload a image or a YouTube video to slideshow. But when i click send, the server doesn't catch the data. I can see in my browsers network panel that I send a post request to the server that is populated with the parameters. But when the server gets the request the $_POST array is empty.
The code worked before but I haven't been working on for like a half year but it worked just a few weeks ago. Only thing I have been doing is working on another website and change some PHP settings at my webhotel but I can't find any that would stop POST requests.
I removed all the input fields since SO wouldn't let me post so much code.
<form id="slideForm" action="php/upload.php" method="post" enctype="multipart/form-data">
<fieldset id="media">
<legend>Load upp new slide </legend>
<label for="mediaType">Media type</label>
<select name="mediaType" id="mediaType">
<option value="empty" selected="selected"></option>
<option value="image">Image (jpeg, jpg, png)</option>
<option value="youtube">Youtube</option>
</select>
<div id="local"> <!-- Only if image is selected -->
<label for="localImageLocal">Local file</label>
<input type="radio" name="localImage" id="localImageLocal" value="local" />
<label for="lovalImageUrl">Internet image</label>
<input type="radio" name="localImage" id="localImageUrl" value="url" />
</div>
<div id="image">
<div id="imageFileDiv">
<label for="imageFile">Upload image (jpeg, jpg, png)</label>
<input type="hidden" name="MAX_FILE_SIZE" value="4000000" />
<input type="file" name="imageFile" id="imageFile" accept=".jpeg,.jpg,.png" />
</div>
<div id="urlImageDiv">
<label for="urlImage">Url to image</label>
<input type="url" name="urlImage" id="urlImage">
<br />
<div id="imageName">
<label for="urlImageName">Name the image</label>
<input type="text" name="urlImageName" id="urlImageName" />
</div>
</div>
</div>
<div id="youtube">
<label for="youtubeUrl">Url to video </label>
<input type=url name="youtubeUrl" id="youtubeUrl" checked />
</div>
</fieldset>
<fieldset id="settingsField">
<div id="settings">
<div id="effects">
<h2>Effects</h2>
<label for="effectNone">None</label>
<input type="radio" name="effect[]" id="effectNone" value="none" checked />
<label for="effectBlink">Blink</label>
<input type="checkbox" name="effect[]" id="effectBlink" value="blink"/>
<label for="effectHorn">Horn</label>
<input type="checkbox" name="effect[]" id="effectHorn" value="horn"/>
</div>
<br />
<div id="videoSettings">
<!--<label for="playToEnd"> Play to end off video </label>
<input type="checkbox" name="playToEnd" id="playToEnd" value="playToEnd"> -->
<span> Video will allways run to the end </span>
</div>
<div id="duration">
<label for="duration" >Image duration: </label>
<span id="durationLabel">10</span>
<input type="range" name="duration" id="durationRange" min="1" value="10" max="180" step="1" />
</div>
<br />
<div id="priority">
<label for="priority">Priority</label>
<input type="number" name="priority" id="priority" min="0" value="0"/>
</div>
<br />
<div id="startSettings">
<label for="startNow"> Start now </label>
<input type="checkbox" name="startNow" id="startNow" value="true" checked/>
<div id="timeAndDate">
<label for="startDate">Start date</label>
<input type="text" name="startDate" id="startDate" value="2015-01-01" />
<label for="startTime">Start time</label>
<input type="text" name="startTime" id="startTime" value="00:00:00" />
<br />
<label for="endDate">End date</label>
<input type="text" name="endDate" id="endDate" value="2015-01-02" />
<label for="endTime">End time</label>
<input type="text" name="endText" id="endTime" value="24:00:00" />
</div>
</div><!-- END startSettings -->
</div><!-- END settings -->
<input type="submit" name="submit" id="submit" value="ADD"/>
</fieldset>
</form>
Booth the $_POST and $_REQUEST is empty
require_once("config.php");
var_dump($_REQUEST);
if(!isset($_POST["submit"])){
exit("No data");
}
My settings:

Related

Form submittion wont read required in the select tag

I have a page where the users can register accounts which looks like this:
The problem is, when the user doesn't or forgot to fill up gender, it just submits the form without an error even if I have a required function on the select tag. It's only the gender that I'm having problems with. The required function works with the other fields.
here's my form:
<div class="main">
<div class="one">
<div class="register">
<center><h3>Add Account</h3></center>
<form name="reg" action="code_exec.php" onsubmit="return validateForm()" method="post">
<div>
<label>ID</label>
<input type="text" name="id" required>
</div>
<div>
<label>First Name</label>
<input type="text" name="firstname" required>
</div>
<div>
<label>Last Name</label>
<input type="text" name="lastname" required>
</div>
<div>
<label>Email</label>
<input type="text" name="email" placeholder="user#teamspan.com" required>
</div>
<div>
<label>Username</label>
<input type="text" name="username" required>
</div>
<div>
<label>Password</label>
<input type="password" name="password" required>
</div>
<div>
<label>Street Address</label>
<input type="text" name="street" required>
</div>
<div>
<label>Town/Suburb</label>
<input type="text" name="town" required>
</div>
<div>
<label>City</label>
<input type="text" name="city" required>
</div>
<div>
<label>Phone No.</label>
<input type="text" name="phone">
</div>
<div>
<label>Landline No.</label>
<input type="text" name="landline">
</div>
<div>
<label>Gender</label>
<select name="gender" required>
<option disabled selected hidden>Select Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</div>
<div>
<label>User Levels</label>
<select name="user_levels" required>
<option disabled selected hidden>Select Access Level</option>
<option value="0">Employee</option>
<option value="1">Administrator</option>
<option value="2">Manager</option>
<option value="1">HR</option>
</select>
</div>
<div>
<label>Date</label>
<input type="text" readonly="readonly" name="date" value="<?php echo date("Y/m/d");?>" required>
</div>
<div>
<label>Sick Leave</label>
<input type="text" name="sickleave" required>
</div>
<div>
<label>Vacation Leave</label>
<input type="text" name="vacationleave" required>
</div>
<div>
<label>Picture (Link)</label>
<input type="text" name="picture" value="img/emp/" required>
</div>
<div>
<label></label>
<input type="submit" name="submit" value="Add Account" class="button" style="color: white;" />
<a href="hr_panel.php"><input type="button" value="Back" class="button" style="color: white;" />
</div>
</form>
</div>
</div>
You need to give value="" on first option i.e.Select Gender. Try following code
<div class="main">
<div class="one">
<div class="register">
<center><h3>Add Account</h3></center>
<form name="reg" action="code_exec.php" onsubmit="return validateForm()" method="post">
<div>
<label>ID</label>
<input type="text" name="id" required>
</div>
<div>
<label>First Name</label>
<input type="text" name="firstname" required>
</div>
<div>
<label>Last Name</label>
<input type="text" name="lastname" required>
</div>
<div>
<label>Email</label>
<input type="text" name="email" placeholder="user#teamspan.com" required>
</div>
<div>
<label>Username</label>
<input type="text" name="username" required>
</div>
<div>
<label>Password</label>
<input type="password" name="password" required>
</div>
<div>
<label>Street Address</label>
<input type="text" name="street" required>
</div>
<div>
<label>Town/Suburb</label>
<input type="text" name="town" required>
</div>
<div>
<label>City</label>
<input type="text" name="city" required>
</div>
<div>
<label>Phone No.</label>
<input type="text" name="phone">
</div>
<div>
<label>Landline No.</label>
<input type="text" name="landline">
</div>
<div>
<label>Gender</label>
<select name="gender" required>
<option disabled selected value="">Select Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</div>
<div>
<label>User Levels</label>
<select name="user_levels" required>
<option disabled selected hidden>Select Access Level</option>
<option value="0">Employee</option>
<option value="1">Administrator</option>
<option value="2">Manager</option>
<option value="1">HR</option>
</select>
</div>
<div>
<label>Date</label>
<input type="text" readonly="readonly" name="date" value="<?php echo date("Y/m/d");?>" required>
</div>
<div>
<label>Sick Leave</label>
<input type="text" name="sickleave" required>
</div>
<div>
<label>Vacation Leave</label>
<input type="text" name="vacationleave" required>
</div>
<div>
<label>Picture (Link)</label>
<input type="text" name="picture" value="img/emp/" required>
</div>
<div>
<label></label>
<input type="submit" name="submit" value="Add Account" class="button" style="color: white;" />
<a href="hr_panel.php"><input type="button" value="Back" class="button" style="color: white;" />
</div>
</form>
</div>
</div>
Because you havent put value="" in Option
Try By This
<option value="" disable hidden>Select Gender</option>

How do I use 1 submit button to do 2 actions?

I'm trying to submit data to a list in my mail chimp but also allow the user to upload a file.
Here is my code, the first chunk is the mailchimp autogenerated form which is submitted via:
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
and then it's followed by the basic code to submit a file. But at the moment both functions have a submit button. I want only one. Can anyone help?
<body>
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="http://test.us7.list-manage.com/subscribe/post?u=d12b70d4bb1e08c1568d5b392&id=bfb41cbf75" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<h2>Subscribe to our test mailing list</h2>
<div class="indicates-required">
<span class="asterisk">*</span> indicates required
</div>
<div class="mc-field-group">
<label for="mce-EMAIL">
Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
<label for="mce-FNAME">First Name </label>
<input type="text" value="" name="FNAME" class="" id="mce-FNAME">
</div>
<div class="mc-field-group">
<label for="mce-LNAME">Last Name </label>
<input type="text" value="" name="LNAME" class="" id="mce-LNAME">
</div>
<div class="mc-field-group input-group">
<strong>Interests </strong>
<ul>
<li><input type="checkbox" value="1" name="group[5597][1]" id="mce-group[5597]-5597-0"><label for="mce-group[5597]-5597-0">Interest 1</label></li>
<li><input type="checkbox" value="2" name="group[5597][2]" id="mce-group[5597]-5597-1"> <label for="mce-group[5597]-5597-1">Interest 2</label></li>
<li><input type="checkbox" value="4" name="group[5597][4]" id="mce-group[5597]-5597-2"><label for="mce-group[5597]-5597-2">Interest 3</label></li>
</ul>
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div>
</div>
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
<div class="clear">
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
</form>
</form>
</body>
You could accomplish this by routing the MailChimp information through your upload_file.php file.
MailChimp has a great API that you can use for more than just adding a subscriber to a list. You would specifically want the listSubscribe() function. There are some great examples on that page.
Here's more documentation on MailChimp's API: http://apidocs.mailchimp.com/api/2.0/
So in your HTML, you would want to remove the second submit button and make it one form with action="upload_file.php". The PHP file would upload the file, then use the API to submit the data to MailChimp.
You html should look like this:
<body>
<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<h2>Subscribe to our test mailing list</h2>
<div class="indicates-required">
<span class="asterisk">*</span> indicates required
</div>
<div class="mc-field-group">
<label for="mce-EMAIL">
Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
<label for="mce-FNAME">First Name </label>
<input type="text" value="" name="FNAME" class="" id="mce-FNAME">
</div>
<div class="mc-field-group">
<label for="mce-LNAME">Last Name </label>
<input type="text" value="" name="LNAME" class="" id="mce-LNAME">
</div>
<div class="mc-field-group input-group">
<strong>Interests </strong>
<ul>
<li><input type="checkbox" value="1" name="group[5597][1]" id="mce-group[5597]-5597-0"><label for="mce-group[5597]-5597-0">Interest 1</label></li>
<li><input type="checkbox" value="2" name="group[5597][2]" id="mce-group[5597]-5597-1"> <label for="mce-group[5597]-5597-1">Interest 2</label></li>
<li><input type="checkbox" value="4" name="group[5597][4]" id="mce-group[5597]-5597-2"><label for="mce-group[5597]-5597-2">Interest 3</label></li>
</ul>
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div>
</div>
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<div class="clear">
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
</body>

undefined index in php using post but it can echo the value using request on update.php

I have these two files and i am updating a table but on the update.php file i get error saying Notice: Undefined index: pname , $pcode...... $pname = $_POST["pname"]; here i am storing pname value in pname variable.but it shows error
<address>
<div class="control-group">
<label class="control-label">Product Name:</label>
<div class="controls">
<input id="pname" name="pname" type="text" value="<?php echo $PName; ?>"
class="input-xlarge">
<p class="help-block"></p>
</div>
</div>
<div class="control-group">
<label class="control-label">Product Code:</label>
<div class="controls">
<input id="code" name="pcode" type="text" value="<?php echo $PCode; ?>"
class="input-xlarge">
</div>
</div>
<div class="control-group">
<label class="control-label">Product Price:</label>
<div class="controls">
<input id="price" name="pprice" type="text" value="<?php echo $PPrice; ?>"
class="input-xlarge">
</div>
</div>
<div class="control-group">
<label class="control-label">Availability:</label>
<div class="controls">
<select id="stock" name="stock" class="input-xlarge">
<option value="1" selected="selected">Available</option>
<option value="0">Not Available</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label">Product Description:</label>
<div class="controls">
<textarea rows="4" cols="50" name="description" > <?php echo $PDescription; ?> </textarea>
</div>
</div>
<div class="control-group">
Picture 1 :
<div class="controls">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<input type="file" name="pic1"
class="input-xlarge">
</div>
</div>
<div class="control-group">
Picture 2 :
<div class="controls">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<input type="file" name="pic2"
class="input-xlarge">
</div>
</div>
<div class="control-group">
Picture 3 :
<div class="controls">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
<input type="file" name="pic3"
class="input-xlarge">
</div>
</div>
<div class="control-group">
<div class="controls">
<input type='hidden' name='id' value="<?php echo $ID; ?>"><br/>
<input type="submit" value="UPDATE" class="btn-large" />
</div>
</div>
</form>
Do you check for form submit?
if (isset($_POST["pname"])) {
// do all your form processing here.
}
$pname= (isset($_POST["pname"]) ? $_POST["pname"] : "");
this will check if pname exists in $_POST and then sets it.
you receive that error because you dont have set $_POST["pname"]

html5 input date empty on post php

I'm using the HTML5 input date type. After posting, I see this input empty, and all the other inputs (HTML4 types) are OK.
What could be the reason?
This is my form:
<form action="/SGM/index.php?r=manager/addcoach_post" method="post">
<div class="registerFeildArea2">
<div class="registerTxtP2">Family name</div>
<div class="registerFeild">
<input name="lname" type="text" value="" size="" class="registerFeildValue" />
</div>
</div>
<div class="registerFeildArea">
<div class="registerTxtP2">First name</div>
<div class="registerFeild">
<input name="fname" type="text" value="" size="" class="registerFeildValue" />
</div>
</div>
<div class="registerFeildArea2">
<div class="registerTxtP2">Address</div>
<div class="registerFeild">
<input name="address" type="text" value="" size="" class="registerFeildValue" />
</div>
</div>
<div class="registerFeildArea">
<div class="registerTxtP2">City</div>
<div class="registerFeild">
<input name="city" type="text" value="" size="" class="registerFeildValue" />
</div>
</div>
<div class="registerFeildArea2">
<div class="registerTxtP2">Birthdate</div>
<div class="birthDayFeild">
<input name="bdate" id="meeting" type="date" value="2011-01-13"/>
</div>
</div>
<div class="AddBtn"><input name="Next" type="submit" value="הוסף" class="AddBtnValue" /></div>
</form>
And when I get to the actionAddcoach_post(), all the fields are OK except for the bdate.
What could be the reason?

Modx css issue not pulling in styles on the form

I'm editing a site using Modx cms.
I'm trying to add a contact form to the contact page. I already have one in the sidebar specified in a template. The code on the contact page form points to the same div tags, but it isn't picking up any of the css.
any ideas why this is happening. Do I need some kind of plugin?
Thanks for all your help
Regards
Judi
<div class="enquiry-form-top">
<h2>Enquiry Form</h2>
</div>
<div class="enquiry-form">
<form class="enquiry" id="enquiry" action="mailer.php" method="post">
<fieldset>
<legend>Enquiry Form</legend>
<div class="form-field">
<label for="Name">Name:</label>
<input type="text" id="Name" name="Name" value="">
</div>
<input type="hidden" name="thankspage" value="thank-you.html">
<input type="hidden" name="subject" value="Enquiry Form">
<div class="form-field">
<label for="Address"> Address:</label>
<input type="text" id="Address" name="Address" value="">
<input type="text" id="Address2" name="Address2" value="">
<input type="text" id="Address3" name="Address3" value="">
</div>
<div class="form-field">
<label for="DOB">DOB:</label>
<input id="DOB" type="text" name="DOB" value="" />
</div>
<div class="form-field">
<label for="Total-Fund-Size">Total Fund Size:</label>
<input id="Total-Fund-Size" type="text" name="Total-Fund-Size" value="" />
</div>
<div class="form-field">
<label for="Number-Of-Funds">Number Of Funds:</label>
<input id="Number-Of-Funds" type="text" name="Number-Of-Funds" value="" />
</div>
<div class="form-field">
<label for="Lump-Sum-Benefit">Has Lump Sum <br/>Benefit Been Taken:</label>
<ul>
<li>Yes <input type="checkbox" name="Lump-Sum-Benefit" id="Lump-Sum-Benefit" value="Yes" /></li>
<li>No <input type="checkbox" name="Lump-Sum-Benefit" id="Lump-Sum-Benefit2" value="No" /></li>
</ul>
</div>
<div class="form-field">
<label for="Telephone-Number">Telephone Number:</label>
<input type="text" id="Telephone-Number" name="Telephone-Number" value="">
</div>
<div class="form-field">
<label for="Best-Time-To-Contact">Best Time To Contact:</label>
<input type="text" id="Best-Time-To-Contact" name="Best-Time-To-Contact" value="">
</div>
<div class="form-field">
<label for="Email">Email:</label>
<input type="text" id="Email" name="Email" value="">
</div>
<div class="form-field">
<img src="CaptchaSecurityImages.php" alt="">
<label for="security_code"> Security Code: </label>
<input type="text" id="security_code" name="security_code">
</div>
<div class="form-buttons">
<input type="image" name="Submit" value="Submit" src="images/annuity/submit_button.gif">
</div>
</fieldset>
</form>
There is no reason I can think of for this to happen, and you don't need any plug-ins.
Once the page is rendered it is of course just HTML and it doesn't matter if it was made in modx or any other system.
Can you investigate the page using Firebug and make sure the Stylesheet is loading?
Maybe the form that is working is enclosed in a div with a class and all the styles are set in the style sheet as follows (ie. Children of the containing div)
.enclosingdiv .form-field
That would explain why your form isn't picking up the styles.
Also you should check out eform (Package, wiki) it's great for simple contact forms.

Categories