I have a simple INSERT that is not working. Can you php/mySQL experts do a quick scan. When I process the code, it does say "successful" i.e. "1 record added'" and "successfully created directory" - but there is NO new directory I see on the server AND it adds a record in the db but all the fields are empty?
include("_inc/config.php");
$sql = "INSERT INTO members (id, active, namefirst, namelast, email, username, password, birthyear, gender, country, postalcode, education, dimension, referredby, pic_profile, pic_background, origination, customerid) VALUES ('','$_POST[active]','$_POST[namefirst]','$_POST[namelast]','$_POST[email]','$_POST[username]','$_POST[password]','$_POST[birthyear]','$_POST[gender]','$_POST[country]','$_POST[postalcode]','$_POST[education]','$_POST[dimension]','$_POST[referredby]','$_POST[pic_profile]','$_POST[pic_background]','$_POST[origination]','$_POST[customerid]')";
$newdir=$_POST['username'];
if (!mysql_query($sql,$con)){
die('Error: ' . mysql_error());
}
echo "1 record added";
echo "<br><br>";
// Build Directories
mkdir("../".$newdir,0777);
chmod("../".$newdir,0777);
mkdir("../".$newdir."/assets/",0777);
chmod("../".$newdir."/assets/",0777);
if("../".mkdir($newdir, 0777, true))
{
echo 'successfully created directory';
}
else
{
die('problem creating directory');
}
mysql_close($con)
FORM
<form role="form" name="form" action="mpx_signup_process.php">
<div class="form-group">
<label for="nameandemail">Name and Email</label>
<input name="namefirst" class="form-control" placeholder="First Name">
</div>
<div class="form-group">
<input name="namelast" class="form-control" placeholder="Last Name">
</div>
<div class="form-group">
<input name="email" type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
</div>
<div class="form-group"><hr></div>
<div class="form-group">
<label for="accountinfo">Account Information</label>
<input name="username" class="form-control" id="exampleInputPassword1" placeholder="User Name">
</div>
<div class="form-group">
<input name="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-group">
<input name="password" class="form-control" id="exampleInputPassword1" placeholder="Password Repeat">
</div>
<hr />
<div class="form-group">
<label for="personalinfo">Personal Information</label>
<h3>Country</h3>
<select name="country" class="form-control">
<option value="USA">United States</option>
<option value="UMI">United States Minor Outlying Islands</option>
<option value="USA">- - - - - -</option>
<option value="ALA">Åland Islands</option>
<option value="ALB">Albania</option>
<option value="DZA">Algeria</option>
<option value="ASM">American Samoa</option>
</select>
</div>
<div class="form-group">
<label for="referredby">Postal Code</label>
<input name="postalcode" class="form-control" id="exampleInputPostalCode" placeholder="Postal Code">
</div>
<div class="form-group">
<label for="gender">Gender</label>
<div class="radio">
<label>
<input type="radio" name="gender" id="optionsRadios4" value="01">
Male
</label>
<label>
<input type="radio" name="gender" id="optionsRadios5" value="02">
Female
</label>
<label>
<input type="radio" name="gender" id="optionsRadios6" value="03">
Other
</label>
</div>
</div>
<div class="form-group">
<label for="dateofbirth">Date of Birth</label>
<select name="birthyear" class="form-control">
<?php
for($i = 2010 ; $i > 1920; $i--){
echo "<option value=".$i.">$i</option>";
}
?>
</select>
</div>
<div class="form-group">
<label for="education">Education</label>
<select name="education" class="form-control">
<option value="01">Pre High School</option>
<option value="02">High School</option>
<option value="03">Some College</option>
<option value="04">College Graduate</option>
<option value="05">Graduate Degree</option>
</select>
</div>
<div class="form-group">
<label for="referredby">Referred By</label>
<input name="referredby" class="form-control" id="exampleInputreferredby" placeholder="Referred By">
</div>
<input type="hidden" name="active" value="no">
<input type="hidden" name="dimension" value="00">
<input type="hidden" name="pic_profile" value="mpx_profilepic.jpg">
<input type="hidden" name="pic_background" value="mpx_bsckgroundpic.jpg">
<?php
$date = date('l jS \of F Y h:i:s A');
?>
<input type="hidden" name="origination" value="<?php echo $date; ?>">
<button type="submit" class="btn btn-default">Submit</button>
</form>
In the form, add a method="POST"
<form role="form" name="form" method="POST" action="mpx_signup_process.php">
Because $_POST["username"] is empty the new directory name is empty thus the reason for not creating it I assume.
I would also suggest adding a check to determine if the record was infact inserted. The code above will ALWAYS return "1 record added" which is incorrect. Use something similar to mysql_rows_affected but using mysqli or PDO rather.
if(mysql_affected_rows() > 0)
{
echo "1 record added";
echo "<br><br>";
// Build Directories
mkdir("../".$newdir,0777);
chmod("../".$newdir,0777);
mkdir("../".$newdir."/assets/",0777);
chmod("../".$newdir."/assets/",0777);
}
else
{
echo "No records added";
}
Sure it will always "successfully created directory"!
Please look,
if("../".mkdir($newdir, 0777, true))
When mkdir eval to false (fail), you'll get
if("../" . false)
// or
if("../false") // maybe
// or just
if("../") // maybe, I'm unsure.
and it's non empty string, BTW, it always eval to true ensuring you hit the
echo 'successfully created directory';
In $sql you're not escaping the string properly
the php post variables in $sql are as $_POST[namelast], $_POST[email], etc, whereas it should be $_POST['namelast'], $_POST['email'], etc.
Related
I am working on a web form that includes a select drop down with two options: "Cedula" (in English, "Identification") and "Pasaporte" (in English, "Passport").
Here is an image of my web form so far.
Please help me achieve the following goal: when the user selects "Cedula", they are limited to 10 digits, but when they select "Pasaporte, they are not limited to 10 digits.
Here is my code so far:
<?php
if ($_GET['id']) {
$cliente = $clienteNegocio->recuperar($_GET['id']);
$txtAction = 'Editar';
}else{
$cliente = new cliente();
$txtAction = 'Agregar';
}
?>
<div class="container">
<div class="page-header">
<h1><?php echo $txtAction; ?> Cliente</h1>
</div>
<form role="form" method="post" id="principal">
<input type="hidden" name="id" value="<?php echo $cliente->getId();?>" >
<div class="form-group">
<label for="nombre">Nombre</label>
<input type="text" class="form-control" id="nombre" name="nombre" placeholder="Nombre" value="<?php echo $cliente->getNombre();?>" required>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="apellido">Apellidos</label>
<input type="text" class="form-control" id="apellido" name="apellido" placeholder="Apellido" value="<?php echo $cliente->getApellido();?>" required>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="tipoDoc">Tipo de Documento</label>
<select class="form-control" id="tipoDoc" name="tipoDoc">
<option value="Cedula" <?php if($cliente->getTipoDoc() == 'Cedula') {echo "selected";} ?> >Cedula</option>
<option value="Pasaporte" <?php if($cliente->getTipoDoc() == 'Pasaporte') {echo "selected";} ?> >Pasaporte</option>
</select>
</div>
<div class="form-group">
<label for="nroDoc">Numero de Documento</label>
<input type="number" class="form-control" id="nroDoc" maxlength=10 oninput="if(this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
name="nroDoc" placeholder="Numero de Documento" value="<?php echo $cliente ->getNroDoc();?>" required>
<div class="help-block with-errors"></div>
</div>
There you go.
I have written a javascript function to check the length with you select Pasaporte/Cedula.
Secondly, in <input type = "number"/> you cannot set maxLength. Hence you have to set <input type = "text" />. Also, an onKeyPress event to verify the input as number
<?php
if ($_GET['id']) {
$cliente = $clienteNegocio->recuperar($_GET['id']);
$txtAction = 'Editar';
}else{
$cliente = new cliente();
$txtAction = 'Agregar';
}
?>
<script>
function setMaxLength(){
var inputVal = document.getElementById("tipoDoc")
var selIndex = inputVal.options[inputVal.selectedIndex].value
var inputNum = document.getElementById("nroDoc");
if( selIndex === "Cedula"){
inputNum.maxLength = 10
selIndex.substr(0, 9);
inputNum.value = inputNum.value.substr(0, 9);
} else{
// Set your own limit here
// if selIndex === "Pasaporte"
inputNum.maxLength = 20
}
}
</script>
<div class="container">
<div class="page-header">
<h1><?php echo $txtAction; ?> Cliente</h1>
</div>
<form role="form" method="post" id="principal">
<input type="hidden" name="id" value="<?php echo $cliente->getId();?>" >
<div class="form-group">
<label for="nombre">Nombre</label>
<input type="text" class="form-control" id="nombre" name="nombre" placeholder="Nombre" value="<?php echo $cliente->getNombre();?>" required>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="apellido">Apellidos</label>
<input type="text" class="form-control" id="apellido" name="apellido" placeholder="Apellido" value="<?php echo $cliente->getApellido();?>" required>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label for="tipoDoc">Tipo de Documento</label>
<select class="form-control" id="tipoDoc" name="tipoDoc" onChange="setMaxLength()">
<option value="Cedula" <?php if($cliente->getTipoDoc() == 'Cedula') {echo "selected";} ?> >Cedula</option>
<option value="Pasaporte" <?php if($cliente->getTipoDoc() == 'Pasaporte') {echo "selected";} ?> >Pasaporte</option>
</select>
</div>
<div class="form-group">
<label for="nroDoc">Numero de Documento</label>
<!--
Here onKeyPress method is used to check if the input is a number
in <input type = "number"/> you cannot set maxLength
hence you have to set <input type = "text" />
-->
<input type="text" class="form-control" id="nroDoc" maxlength=10 onkeypress="if ( isNaN(this.value + String.fromCharCode(event.keyCode) )) return false;"
name="nroDoc" placeholder="Numero de Documento" value="<?php echo $cliente ->getNroDoc();?>" required>
<div class="help-block with-errors"></div>
</div>
</form>
</div>
I am trying to work out how to add multiple rows in an 'Order Details' table when a form is submitted. The user is able to select multiple sizes which when submitted, should generate up to N number of rows selected by the user.
Below is my current code for the View file:
<form action="../Controller/NewProduct.php" method="POST">
<h4 align="center"> PRODUCT <b>DETAILS</b> </h4>
<br/>
<div class="form-group">
<label for="categoryid">Category</label>
<select class="form-control" name="categoryid" id="categoryid" required>
<option value="1">Tshirt</option>
<option value="2">Swim Shorts</option>
</select>
</div>
<br/>
<div class="form-group">
<label for="productid">Product ID</label>
<input name="productid" class="form-control" id="productid" required>
</div>
<br/>
<div class="form-group">
<label for="name">Product Name</label>
<input name="name" class="form-control" id="name" required>
</div>
<br/>
<div class="form-group">
<label for="description">Product Description</label><br/>
<textarea name="description" rows="4" class="description" placeholder="Enter product description here." required></textarea>
</div>
<br/>
<div class="form-group">
<label for="size">Size</label>
<select class="form-control" id="size" name="size" multiple required>
<option value="S">S</option>
<option value="M">M</option>
<option value="L">L</option>
<option value="XL">XL</option>
<option value="XXL">XXL</option>
</select>
</div>
<br/>
<div class="form-group">
<label for="colour">Colour</label>
<select class="form-control" id="colour" name="colour" required>
<option value="Burgundy">Burgundy</option>
<option value="Navy Blue">Navy Blue</option>
<option value="Red">Red</option>
<option value="White">White</option>
<option value="Grey">Grey</option>
<option value="Black">Black</option>
<option value="Yellow">Yellow</option>
<option value="Green">Green</option>
<option value="Khaki">Khaki</option>
<option value="Blue">Blue</option>
</select>
</div>
<br/>
<div class="form-group">
<label for="unitprice">Unit Price</label>
<input name="unitprice" class="form-control" id="unitprice" placeholder="Do not include the £ sign." required>
</div>
<br/>
<div class="form-group">
<label for="unitsinstock">Units In Stock</label>
<input name="unitsinstock" class="form-control" id="unitsinstock" required>
</div>
<br/>
<div class="form-group">
<label for="pimage">Product Image</label>
<input name="pimage" class="form-control" id="pimage" placeholder="Enter Image URL" required>
</div>
<br/>
<div class="form-group">
<label for="discount">Discount</label>
<input name="discount" class="form-control" id="discount">
</div>
<br/>
<button type="submit" name="submit" class="btn"><i class="fa fa-check"></i> Done</button>
</form>
This this then the file which is run when the form is submitted:
if (isset($_POST['submit'])) {
require_once 'DatabaseConnection.php';
$statement = $pdo->prepare("INSERT INTO Product (categoryid, name, description, colour, unitprice, pimage, discount, productid)
VALUES (:categoryid, :name, :description, :colour, :unitprice, :pimage, :discount, :productid)");
$statement->bindParam(':categoryid', $categoryid);
$statement->bindParam(':name', $name);
$statement->bindParam(':description', $description);
$statement->bindParam(':colour', $colour);
$statement->bindParam(':unitprice', $unitprice);
$statement->bindParam(':pimage', $pimage);
$statement->bindParam(':discount', $discount);
$statement->bindParam(':productid', $productid);
$categoryid = $_POST['categoryid'];
$name = $_POST['name'];
$description = $_POST['description'];
$colour = $_POST['colour'];
$unitprice = $_POST['unitprice'];
$pimage = $_POST['pimage'];
$discount = $_POST['discount'];
$statement2 = $pdo->prepare("INSERT INTO ProductDetails (unitsinstock, size, productid) VALUES (:unitsinstock, :size, :productid)");
$statement2->bindParam(':size', $size);
$statement2->bindParam(':unitsinstock', $unitsinstock);
$statement2->bindParam(':productid', $productid);
$size = $_POST['size'];
$unitsinstock = $_POST['unitsinstock'];
$productid = $_POST['productid'];
$statement->execute();
$statement2->execute();
header('location:../View/AdminAllProducts.php');
}
?>
An example of what I am trying to achieve is like the following: https://imgur.com/a/SPr14
Pick up the sizes array and work on it in a loop:
$sizes = $_POST['size[]'];
foreach ( $sizes as $size )
{
// ... your code of statement2 :
statement2 = $pdo->prepare("INSERT INTO ProductDetails (unitsinstock, size, productid) VALUES (:unitsinstock, :size, :productid)");
$statement2->bindParam(':size', $size);
$statement2->bindParam(':unitsinstock', $unitsinstock);
$statement2->bindParam(':productid', $productid);
$unitsinstock = $_POST['unitsinstock'];
$productid = $_POST['productid'];
$statement->execute();
$statement2->execute();
}
You should change the selects that can be multiple select to be an array (ex: size([]) the in PHP you should work the request value as an array.
You can also concatenat the string in the values to be inserted in order to only do one request to the database.
I'm developing a script for online admission in a website. Below is php code of the page. The problem is that it's not submitting.
<?php
include ("include/header.php"), include ("include/config.php");
if(isset($_POST['applyAdmission'])) {
$admission_no = $_POST['admission_no'];
$f_name = $_POST['f_name'];
$l_name = $_POST['l_name'];
$p_add = $_POST['p_add'];
$c_add = $_POST['c_add'];
$dob = $_POST['dob'];
$education = $_POST['education'];
$mobile = $_POST['mobile_no'];
$course = $_POST['course'];
$subjects = $_POST['subjects'];
$timing = $_POST['timing'];
$filepath_pic = $_FILES['picture']['name'];
$res_move_pic = move_uploaded_file($_FILES['picture']['tmp_name'], "/admission/".$filepath_pic);
$filepath_sign = $_FILES['sign']['name'];
$res_move_sign = move_uploaded_file($_FILES['sign']['tmp_name'], "/admission/".$filepath_sign);
$agree_terms = $_POST['agree_terms'];
$agree_cond = $_POST['agree_cond'];
if ($res_move_pic == 1 && $res_move_sign == 1 ) {
$query = "INSERT into online_admission (f_name, l_name, p_add, c_add, dob, degree, mobile_no, course, subjects, timing, pic, sign, agree_terms, agree_cond, applied_on)
values ('$f_name','$l_name','$p_add','$c_add','$dob','$education','$mobile','$course','$subjects','$timing','$filepath_pic','$filepath_sign','$agree_terms','$agree_cond','now()')";
$res = mysql_query($query) or die("ERROR: Unable to insert into database.");
if ($res == 1) {
header('Location:http://adarshclasses.in/admission_success.php/');
exit();
} else {
header('Location:http://adarshclasses.in/admission_failed.php/');
exit();
}
} else {
echo "Error in updateing profile pic and sign";
}
} else {
//echo "Please submit the form, thanks!";
}
;?>
Everything in form is correct like I added same name in form which i used in $_POST but still it's not working, please help me to fix this issue.
Here is html codes of form:
<form class="form-horizontal" id="admission_form" method="post" action="" enctype="multipart/form-data">
<!--div class="row">
<div class="col-lg-6">
<label for="admission_no"> Admission No. </label>
<input type="hidden" class="form-control" name="admission_no" value="<?php echo $admission_no ;?>" readonly disabled>
</div>
</div--><br>
<div class="row">
<div class="col-lg-6">
<label for="f_name"> First Name <span class="required">*</span> </label>
<input type="text" class="form-control" name="f_name" placeholder="Your first name" value="<?php echo $f_name ;?>" required>
</div>
<div class="col-lg-6">
<label for="l_name"> Last Name <span class="required">*</span></label>
<input type="text" class="form-control" name="l_name" placeholder="Your last name" value="<?php echo $l_name ;?>" required>
</div>
</div><br>
<div class="row">
<div class="col-lg-12">
<label for="p_add"> Permanent Address <span class="required">*</span></label>
<textarea class="form-control" name="p_add" placeholder="Please write your permanent address" value="<?php echo $p_add ;?>" required></textarea>
</div>
</div><br>
<div class="row">
<div class="col-lg-12">
<label for="c_add"> Current Address in Jodhpur <span class="required">*</span></label>
<textarea class="form-control" name="c_add" placeholder="Please write your address where you currently living" value="<?php echo $c_add ;?>" required></textarea>
</div>
</div><br>
<div class="row">
<div class="col-lg-6">
<label for="dob"> Date of birth <span class="required">*</span></label>
<input type="date" class="form-control" name="dob" placeholder="Your date of birth eg:- 25/11/1996" value="<?php echo $dob ;?>" required>
</div>
<div class="col-lg-6">
<label for="education"> Recent passed degree/exam - </label>
<input type="text" class="form-control" name="education" placeholder="for example - BA/ B.Sc etc." value="<?php echo $education ;?>" >
</div>
</div><br>
<div class="row">
<div class="col-lg-6">
<label for="mobile_no"> Mobile Number <span class="required">*</span></label>
<input type="number" class="form-control" name="mobile_no" placeholder="Enter your mobile number, eg - 8384991980" value="<?php echo $mobile_no ;?>" required>
</div>
<div class="col-lg-6">
<label for="course"> Select course <span class="required">*</span> </label>
<select class="form-control" name="course" required>
<option value="none"> --- Select one course --- </option>
<option value="IAS"> IAS </option>
<option value="RAS"> RAS </option>
<option value="Police constable"> Police constable </option>
<option value="SI"> SI </option>
<option value="Railway"> Railway </option>
<option value="REET"> REET </option>
<option value="Teacher"> Teacher </option>
<option value="Patwar"> Patwar </option>
<option value="Bank PO"> Bank PO </option>
<option value="Jr Accountant"> Jr Accountant </option>
<option value="Rajasthan police"> Rajasthan police </option>
<option value="SSC (10+2)"> SSC (10+2) </option>
</select>
</div>
</div><br>
<div class="row">
<div class="col-lg-6">
<label for="subjects"> Subjects - </label>
<input type="text" class="form-control" name="subjects" placeholder="Enter your subject you want to read" value="<?php echo $subjects ;?>" required>
</div>
<div class="col-lg-6">
<label for="timing"> Classes Timing - </label>
<input type="text" class="form-control" name="timing" placeholder="Your preferred time for coaching" value="<?php echo $timing ;?>" required>
</div>
</div><br>
<div class="row">
<div class="col-lg-6">
<label for="picture"> Upload your picture <span class="required">*</span></label>
<input type="file" class="form-control" name="picture" required>
</div>
<div class="col-lg-6">
<label for="sign"> Upload your signature <span class="required">*</span></label>
<input type="file" class="form-control" name="sign" required>
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<input type="checkbox" aria-label="..." name="agree_terms" value="1"> I agree with Rules and Regulations mentioned below.<br>
<input type="checkbox" aria-label="..." name="agree_cond" value="1"> I hearbly declare that Adarsh Classes can use my pictures after my selection for advertising purpose.
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<button type="text" name="submit" class="btn btn-success btn-lg btn-block" name="applyAdmission"> Submit my application form </button>
</div>
</div>
</div>
</form>
The reason behind that in the input type of the HTML Page for the submit you are using <input type="button"
instead of <input type="submit". Use <input type="submit" that's work.
Example:
<input type="submit" name="" value="Submit">
Changed
<button type="text">
to
<button type="submit">
Change
button type="text" to type="button" Or input type ="submit/button"
You need to change this code:
<button type="text" name="submit" class="btn btn-success btn-lg btn-block" name="applyAdmission"> Submit my application form </button>
with below code :
<input type="submit" name="applyAdmission" value="Submit my application form" class="btn btn-success btn-lg btn-block" />
You also need to make sure that your wrote PHP code in same file, otherwise you have to add PHP file name in action tag in below line:
<form class="form-horizontal" id="admission_form" method="post" action="" enctype="multipart/form-data">
You also have some PHP error in your code, so you have to add first line in your PHP code and then fix your PHP Fatal error.
ini_set('display_errors', '1');
I see a little syntax error and I think fixing this will fix your issue.
Change
include ("include/header.php"), include ("include/config.php");
to
include ("include/header.php");
include ("include/config.php");
To show you the syntax error, here is an example:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
include("test.php"), include("someother.php");
The response:
Parse error: syntax error, unexpected ',' in ...\tests\includeTest.php on line 6
Incorrect input type
You should also change your button type.
Change
<button type="text"...
to
<button type="submit"...
Change <button> to <input>. Buttons can work with javascript but with only php button cant work with post data. You can not get POST data by <button>. For this you have to use <input>
Change this
<button type="text" name="submit" class="btn btn-success btn-lg btn-block" name="applyAdmission"> Submit my application form </button>
to
<input type="submit" name="applyAdmission">
Second:
Here is looking syntax error include ("include/header.php"), include ("include/config.php");
PHP requires instructions to be terminated with a semicolon at the end of each statement. Make them seperate by ; not by ,.
include ("include/header.php");
include ("include/config.php");
You can see documentation for more deep information
I have a page which contains a select box which is used to select a particular user. I also have two radiobuttons for selecting date range. This page is for generating user reports based on the selections.
At present when I select the user and preferred date ranges and clicks on submit button reports are generated properly but my selection in select box will be reset to default after submitting.Here My select box is populated from mysql table.
My task is to retain the select box value even after form submit. I have tired so many ways but nothing worked. Can anyone please help me out with this..
Here is my code:
HTML
<div class="box-container-toggle">
<form class="form-horizontal" name="reportform" id="reportform" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST" >
<div class="box-content">
<fieldset>
<legend>Developer Reports</legend>
<div class="control-group">
<label class="control-label" for="select01">Select Developer</label>
<div class="controls">
<select id="select01" class="chzn-select" name="selectdev" onChange="getapp(this.value)">
<option value="">Select developer</option>
<?php
$qry="select user_id from tab_user_login where type='Developer' and status='approved'";
$res=mysql_query($qry);
while($row=mysql_fetch_array($res))
{
$devid=$row[0];
$qry1="select name from tab_user where user_id='$devid'";
$res1=mysql_query($qry1);
while($row1=mysql_fetch_array($res1))
{
?>
<option value="<?php echo $devid;?>" <?php if($dev!="") { if($dev==$devid) {echo 'selected'; } } ?> ><?php echo $row1[0];?></option>
<?php
}
}
?>
</select>
</div>
</div>
<h3> Select Date Range </h3>
<div class="control-group">
<div class="controls">
<label>
<input type="radio" name="selectdateradio" value="selectdaterange" onChange="enableblock()"> Select a Date Range
<div class="control-group" id="daterange" style="display:none">
<label class="control-label" for="select01">Select Date</label>
<div class="controls">
<select id="select01" name="selectdate" id="selectdate" onChange="getYesterdaysDate(this.value)">
<option value="Today" >Today</option>
<option value="Yesterday" >Yesterday</option>
<option value="Last 7 Days" >Last 7 Days</option>
<option value="Last 30 Days" >Last 30 Days</option>
<option value="This Week" >This Week</option>
<option value="This Month" >This Month</option>
<!--<option value="Last 6 Months" >Last 6 Months</option>-->
</select>
<input type="hidden" name="hiddendate" value="" >
<input type="hidden" name="hiddennext" value="" >
</div>
</div>
</label>
<label>
<input type="radio" name="selectdateradio" value="selectcustomdate" onChange="enablecustomblock()"> Select Custom Date
<div class="control-group" id="customdaterange" style="display:none">
<div class="control-group">
<label class="control-label" for="date01">Start input</label>
<div class="input-append date datepicker" data-date="2012-02-12" data-date-format="yyyy-mm-dd">
<input name="start_date" id="start_date" type="text"/><span class="add-on "><i class="icon-calendar"></i></span>
</div>
<!--<div class="controls">
<input type="text" class="input-xlarge datepicker" name="start_date" id="start_date" onChange="show()"/>
</div>-->
</div>
<div class="control-group">
<label class="control-label" for="date01">End Date</label>
<div class="input-append date datepicker" data-date="2012-02-12" data-date-format="yyyy-mm-dd">
<input name="end_date" id="start_date" type="text"/><span class="add-on "><i class="icon-calendar"></i></span>
</div>
<!-- <div class="controls">
<input type="text" class="input-xlarge datepicker" name="end_date" id="end_date" onChange="show()"/>
</div> -->
</div>
</div>
</label>
</div>
</div>
<div class="form-actions">
<input type="submit" class="btn btn-primary" name="submit" value="Run Reports" >
<button type="reset" class="btn">Reset</button>
</div>
</fieldset>
</div>
</form>
<?php
if(isset($_POST['submit']))
{
$dev=$_POST['selectdev'];
$qryy1="select name from tab_user where user_id='$dev'";
$ress1=mysql_query($qryy1);
$roww1=mysql_fetch_array($ress1);
$devname=$roww1[0];
$selected=$_POST['selectdateradio'];
$customstart=$_POST['start_date'];
$customend=$_POST['end_date'];
$postdate=$_POST['selectdate'];
$hide=$_POST['hiddendate'];
$hidden=date("Y-m-d", strtotime($hide));
$hide1=$_POST['hiddennext'];
$hidden1=date("Y-m-d", strtotime($hide1));
date_default_timezone_set("Asia/Kolkata");
$today=date('Y-m-d');
/*$click=0;
$imp=0;
$install=0;
$rev=00.00;
$active=0;*/
}
else
{
}
if($_POST['selectdev']=='')
$devname='All Developer';
if($_POST['selectdate']=='')
$postdate="";
?>
</div>
You must set posted variable before generate the select elements. then you can check the current developer
please try this code before generate select element (for example above the <div class="box-container-toggle"> ) :
<?php
if(isset($_POST['selectdev']) && $_POST['selectdev']!='') {
$selectdev = $_POST['selectdev'];
}
?>
Then Use your checking condition as below
<select id="select01" class="chzn-select" name="selectdev" onChange="getapp(this.value)">
<option value="">Select developer</option>
<?php
$qry="select user_id from tab_user_login where type='Developer' and status='approved'";
$res=mysql_query($qry);
while($row=mysql_fetch_array($res))
{
$devid=$row[0];
$qry1="select name from tab_user where user_id='$devid'";
$res1=mysql_query($qry1);
while($row1=mysql_fetch_array($res1))
{
?>
<option value="<?php echo $devid;?>" <?php if(isset($selectdev) && $selectdev==$devid) echo 'selected="selected"'; ?> ><?php echo $row1[0];?></option>
<?php
}
}
?>
</select>
ok so I use a PHP framework called lemonade it allows me to instead of creating PHP files for each link e.g.
http://example.com/social.php
The code allows me to call functions in our core php script which loads all the important PHP stuff and then i use .tpl files (not i just name them that i don't use the smarty framework - I name them .tpl because they are a template file)
But i seem to be having issues with one page
it sometimes loads fully and other times it's like it dies half way from loading the part that does not show is the sign up section
I have included the full code here
<div class="background">
<div class="contentarea">
<div class="Grid-cell u-size4of4 no-bg">
<div class="banner">
<div class="float_bottom cnetertext">
<center> <span class="slogen" align="center"><?=$lang["frontpage"]["banner"][0];?>
<br>
<?=$lang["frontpage"]["banner"][1];?></span>
</center>
</div>
</div>
</div>
<div class="Grid-cell u-size3of4" style="float:left;">
<div class="internal">
texthere
</div>
</div>
</div>
<script src="//<?=siteurl;?>/template/main/js/registervalidation.js"></script>
<div class="Grid-cell u-size3of4">
<div class="internal">
<h1 class="hevetics">Sign up</h1>
<p class="signuptext">It's free and always will be.</p>
<form action="/signup" name="register" method="post" class="ipetsignup" enctype="multipart/form-data" onsubmit="return registervalidation();">
<label class="half">
<input id="firstname" type="text" name="firstname" placeholder="<?=$lang["form"]["signup"]["FirstName"];?>" onchange="name();" required/>
</label>
<label class="half" style="float:right; margin-right:2%;">
<input id="lastname" type="text" name="lastname" onchange="name();" placeholder="<?=$lang["form"]["signup"]["LastName"];?>" required >
</label>
<label>
<input id="emailone" type="email" name="email" placeholder="<?=$lang["form"]["signup"]["email"];?>" onchange="checkemails();" required >
</label>
<label>
<input id="emailtwo" type="email" name="checkemail" placeholder="<?=$lang["form"]["signup"]["reemail"];?>" onchange="checkemailtwo();" required>
</label>
<label>
<input id="password" type="password" name="password" placeholder="<?=$lang["form"]["signup"]["newpassword"];?>" required>
</label>
<label class="h1">Birthday</label>
<label class="select">
<select name="day">
<option value="00" disabled selected>Day</option>
<?php
for($i=1;$i<=31; $i++)
{
$n = sprintf("%02s", $i);
echo '<option value="'.$n.'">'.$n.'</option>';
}
?>
</select>
</label>
<label class="select">
<select name="month">
<option value="00" disabled selected>Month</option>
<?php
for($i=1;$i<=12; $i++)
{
$n = sprintf("%02s", $i);
echo '<option value="'.$n.'">'.date("F",strtotime('01.'.$n.'.2001')).'</option>';
}
?>
</select>
</label>
<label class="select">
<select name="year">
<option value="00" disabled selected>Year</option>
<?php
$year = date("Y");
for($i=$year-99;$i<=$year; $i++)
{
echo '<option value="'.$i.'">'.$i.'</option>';
}
?>
</select>
</label>
<label>
<input id="signup" type="submit" class="button" value="Sign up">
</label>
</form>
</div>
</div>
</div>
You should look at this line:
<script src="//<?=siteurl;?>/template/main/js/registervalidation.js"></script>
It seems that you forgot to use $ before variable name - it should be probably $siteurl and the other thing is if $siteurl starts with http://. If yes, this line probably should look like:
<script src="<?= $siteurl ?>/template/main/js/registervalidation.js"></script>