I want to my code to do is if i search for batchcode the datas that equals to that batchcode will automatically shows in the texboxes basically each batchcodes has (4)datas in each category thats why i have (4) textboxes...and as you can see i separate the textboxes from the php code because i have plans for it and use javascript for each texboxes.
In my current code its not working and i get an error that says: "Notice: Undefined index: code in C:\xampp\htdocs\test\index.php on line 19"
my current code:
<?php
ob_start();
session_start();
?>
<script type="text/javascript" src="jquery/jquery.js"> </script>
<script type="text/javascript" src="jqueryui/js/jquery-ui-1.10.3.custom.min.js"></script>
<script type="text/javascript" src="Zebra_Dialog-master/public/javascript/zebra_dialog.js"></script>
<link rel="stylesheet" href="Zebra_Dialog-master/public/css/default/zebra_dialog.css" type="text/css">
<link type="text/css" href="jqueryui/css/ui-lightness/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" />
<?php
include('include/connect.php');
$batchcode = $_POST['code'];
$sql = mysql_query("SELECT aic,batchcode,address,name FROM tb_app WHERE batchcode LIKE '$batchcode'");
while($rows = mysql_fetch_array($sql)){
$aic[] = $rows['aic'];
$name[] = $rows['name'];
$address[] = $rows['address'];
}
?>
<html>
<head>
<title>test</title>
</head>
<body>
Search Batchcode:<input type="text" name="code" id="query" /><br />
<form>
<table>
<tr>
<td>
aic: <br />
<input type="text" value="<?php echo $aic[0] ?>" /> <br />
<input type="text" value="<?php echo $aic[1] ?>" /> <br />
<input type="text" value="<?php echo $aic[2] ?>" /> <br />
<input type="text" value="<?php echo $aic[3] ?>" /> <br />
</td>
<td>
Name List: <br />
<input type="text" value="<?php echo $name[0] ?>" /> <br />
<input type="text" value="<?php echo $name[1] ?>" /> <br />
<input type="text" value="<?php echo $name[2] ?>" /> <br />
<input type="text" value="<?php echo $name[3] ?>" /> <br />
</td>
<td>
Address: <br />
<input type="text" value="<?php echo $address[0] ?>" /> <br />
<input type="text" value="<?php echo $address[1] ?>" /> <br />
<input type="text" value="<?php echo $address[2] ?>" /> <br />
<input type="text" value="<?php echo $address[3] ?>" /> <br />
</td>
</form>
<!--search function code-->
<script type="text/javascript">
$(document).ready(function(){
$("#query").autocomplete({
source : 'search.php',
select : function(event,ui){
$("#query").html(ui.item.value);
}
});
});
</script>
</body>
</html>
search.php code:
<?php
$q = $_GET['term'];
mysql_connect("localhost","root","");
mysql_select_db("test");
$query = mysql_query("SELECT batchcode FROM tb_app WHERE batchcode LIKE '$q%'");
$data = array();
while($row = mysql_fetch_array($query)){
$data[]=array('value'=>$row['batchcode']);
}
echo json_encode($data);
?>
I want it to do is after searching and clicking to the specific batchcode in the search textbox the data will automatically shows in the textboxes.
Woah Woah Woah Chappy, direct POST data to sql queries a big no no..
Your error on the other hand is caused because the Global Post array has no array index called 'code'. Mainly because no post data has been sent to the page yet.
You would need to wrap all of that in a if statement.
if(isset($_POST['code'])){
///Logic.
I would do some reading on mysql injections and sanatising post data first though.
Related
I'm inserting variables into database and all values get inserted in the fields with expection of one field (pic). i get this error
<b>Notice</b>: Undefined property: stdClass::$pic in <b>C:\xampp\htdocs\work\app_ion\templates\index_files\addphoto_insert.php</b> on line <b>5</b><br />
JS
.controller("camera_controller",['$scope','$http','$cordovaCamera','$ionicLoading','$ionicPopup','$timeout','$location', function ($scope,$http,$cordovaCamera,$ionicLoading,$ionicPopup,$timeout,$location) {
$scope.email=localStorage.getItem("email");
$http.get('http://localhost/work/app_ion/templates/index_files/addphoto_grab.php?email='+$scope.email).success(function(data){
console.log(JSON.stringify(data));
$scope.grab=data;
});
$http.post("http://localhost/work/app_ion/templates/index_files/addphoto_insert.php",
{'pic':$scope.pic,'email':$scope.item.email,'user_id':$scope.item.profile_id,'country':$scope.item.country,'fpage':$scope.item.fpage})
.success(function(data,status,headers,config){
console.log(data)
});
HTML
<div ng-controller="camera_controller" ng-repeat="item in grab">
<form id="form1" name="form1" method="post">
<input name="user_id" type="hidden" id="user_id" ng-model="item.profile_id" />
<input name="country" type="hidden" id="country" ng-model="item.country" />
<input name="fpage" type="hidden" id="fpage" ng-model="item.fpage" />
<input name="pic" type="hidden" id="pic" ng-model="item.pic" />
<input name="email" type="hidden" id="email" ng-model="item.email" />
</form>
</div>
PHP
<?php require_once('../../../Connections/work.php'); ?>
<?php
$data= json_decode(file_get_contents("php://input"));
$pic= mysql_real_escape_string($data->pic);
$email= mysql_real_escape_string($data->email);
$user_id= mysql_real_escape_string($data->user_id);
$country= mysql_real_escape_string($data->country);
$fpage= mysql_real_escape_string($data->fpage);
mysql_query("INSERT INTO work.pp_change (`pic`,`email`,`user_id`,`country`,`fpage`)VALUES('".$pic."','".$email."','".$user_id."','".$country."','".$fpage."')");
?>
Any help with this error?
I have a profile update form that my users can submit from within their profile page. The profile page uses sessions and therefore the header has been set to redirect if they are not logged in. The problem is, I want the form to redirect to their profile page and show the updated information after the form is submitted. I have tried JS redirects, functions in JS and PHP- with no luck. Here is an example of my php
<?php
if(isset($_SESSION["Username"])){
}else{
header('Location: login.php');
}
?>
Here is the form php
<?php
if(isset($_POST['update'])){
$UpdateFName = $_POST['fname'];
$UpdateLName = $_POST['lname'];
$UpdateEmail = $_POST['email'];
$UpdateAddress = $_POST['address'];
$UpdateCity = $_POST['city'];
$UpdateZip = $_POST['zip'];
$UpdatePrimaryPhone = $_POST['primaryphone'];
$UpdateSecondaryPhone = $_POST['secondaryphone'];
$UpdatePlayerFName = $_POST['playerfname'];
$UpdatePlayerLName = $_POST['playerlname'];
$UpdateTeam = $_POST['team'];
$UpdatePlayerDOB = $_POST['playerdob'];
$sql = $conn->query("UPDATE user_reg SET Fname = '{$UpdateFName}', Lname = '{$UpdateLName}', Email = '{$UpdateEmail}', Address = '{$UpdateAddress}', City = '{$UpdateCity}', Zip = '{$UpdateZip}', PrimaryPhone = '{$UpdatePrimaryPhone}', SecondaryPhone = '{$UpdateSecondaryPhone}', PlayerFName = '{$UpdatePlayerFName}', PlayerLName = '{$UpdatePlayerLName}', Team = '{$UpdateTeam}', PlayerDOB = '{$UpdatePlayerDOB}' WHERE Username= '$user' ");
}
?>
Here is full page
<?php require 'Connections/mysqlilive.php'; ?>
<?php
session_start();
if(isset($_SESSION["Username"])){
}else{
header('Location: login.php');
}
$user = $_SESSION["Username"];
$result = $conn->query("select * from user_reg where Username='$user'");
$row = $result->fetch_array(MYSQLI_BOTH);
$_SESSION["Fname"] = $row['Fname'];
$_SESSION["Lname"] = $row['Lname'];
$_SESSION["Email"] = $row['Email'];
$_SESSION["Address"] = $row['Address'];
$_SESSION["City"] = $row['City'];
$_SESSION["Zip"] = $row['Zip'];
$_SESSION["PrimaryPhone"] = $row['PrimaryPhone'];
$_SESSION["SecondaryPhone"] = $row['SecondaryPhone'];
$_SESSION["PlayerFName"] = $row['PlayerFName'];
$_SESSION["PlayerLName"] = $row['PlayerLName'];
$_SESSION["Team"] = $row['Team'];
$_SESSION["PlayerDOB"] = $row['PlayerDOB'];
$_SESSION["Waiver"] = $row['Waiver'];
$_SESSION["BirthCert"] = $row['BirthCert'];
if(isset($_POST['update'])){
$UpdateFName = $_POST['fname'];
$UpdateLName = $_POST['lname'];
$UpdateEmail = $_POST['email'];
$UpdateAddress = $_POST['address'];
$UpdateCity = $_POST['city'];
$UpdateZip = $_POST['zip'];
$UpdatePrimaryPhone = $_POST['primaryphone'];
$UpdateSecondaryPhone = $_POST['secondaryphone'];
$UpdatePlayerFName = $_POST['playerfname'];
$UpdatePlayerLName = $_POST['playerlname'];
$UpdateTeam = $_POST['team'];
$UpdatePlayerDOB = $_POST['playerdob'];
$sql = $conn->query("UPDATE user_reg SET Fname = '{$UpdateFName}', Lname = '{$UpdateLName}', Email = '{$UpdateEmail}', Address = '{$UpdateAddress}', City = '{$UpdateCity}', Zip = '{$UpdateZip}', PrimaryPhone = '{$UpdatePrimaryPhone}', SecondaryPhone = '{$UpdateSecondaryPhone}', PlayerFName = '{$UpdatePlayerFName}', PlayerLName = '{$UpdatePlayerLName}', Team = '{$UpdateTeam}', PlayerDOB = '{$UpdatePlayerDOB}' WHERE Username= '$user' ");
header("refresh:3; myvbaaccount.php");
echo("Please wait while we update your account.");
}
?>
<!doctype html>
<html>
<head>
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link href="main.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="font-awesome-4.5.0/css/font-awesome.min.css"/>
<link rel="stylesheet" type="text/css" href="dreamcodes/social_icons/tsc_social_icons.css" />
<script src="//use.edgefonts.net/black-ops-one.js"></script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="script.js"></script>
<title>Update My Account</title>
</head>
<body>
<div id="mainwrap">
<div id="headerwrap">
<div id="headertext"><h1 class="header1">valley baseball academy</h1>
<h3 class="header3">Better.Faster.Stronger.</h3></div>
<div id="headerpicture"><img src="Assets/VBA black150px.png" alt="vbablack"> <p class="phone">209.380.7721</p></div>
</div>
<div id="cssmenu">
<ul>
<li><span>Home</span></li>
<li><span>My VBA Home</span></li>
<li><span>Logout</span></li>
<li><span>Contact Us</span></li>
<li><i class="fa fa-facebook-square fa-2x"></i></li>
<li><i class="fa fa-twitter- square fa-2x"></i></li>
<li><i class="fa fa- instagram fa-2x"></i></li>
</ul>
</div>
<div id="topcontent">
<div id="tccol1">
<img class="logo" src="Assets/myvbalogo.png" alt="myvbalogo">
</div>
<div id="tccol2"><h3 class="subheader">Welcome <?php echo $_SESSION['Username']; ?>!</h3></br><h3 class="subheader">Update Your Account</h3>
<form action="" method="post" id="updateaccount">
<div class="formelement2"><input name="fname" type="text" required class="tfield3" id="fname" value="<?php echo $_SESSION["Fname"]; ?>"></div>
<div class="formelement2"><input name="lname" type="text" required class="tfield3" id="lname" value="<?php echo $_SESSION["Lname"]; ?>"></div>
<div class="formelement2"><input name="email" type="text" required class="tfield3" id="email" value="<?php echo $_SESSION["Email"]; ?>"></div>
<div class="formelement2"><input name="primaryphone" type="text" required class="tfield3" id="primaryphone" value="<?php echo $_SESSION["PrimaryPhone"]; ? >"></div>
<div class="formelement2"><input name="secondaryphone" type="text" required class="tfield3" id="secondaryphone" value="<?php echo $_SESSION["SecondaryPhone"]; ?>"></div>
<div class="formelement2"><input name="address" type="text" required class="tfield3" id="address" value="<?php echo $_SESSION["Address"]; ?>"></div>
<div class="formelement2"><input name="city" type="text" required class="tfield3" id="city" value="<?php echo $_SESSION["City"]; ?>"></div>
<div class="formelement2"><input name="zip" type="text" required class="tfield3" id="zip" value="<?php echo $_SESSION["Zip"]; ?>"></div>
<h3 class="subheader">Player Information</h3>
<div class="formelement2"><input name="playerfname" type="text" required class="tfield3" id="playerfname" value="<?php echo $_SESSION["PlayerFName"]; ?>"></div>
<div class="formelement2"><input name="playerlname" type="text" required class="tfield3" id="playerlname" value="<?php echo $_SESSION["PlayerLName"]; ?>"></div>
<div class="formelement2"><input name="team" type="text" required class="tfield3" id="team" value="<?php echo $_SESSION["Team"]; ?>"></div>
<label>Date of Birth</label><div class="formelement2"><input name="playerdob" type="text" required class="tfield3" id="playerdob" value="<?php echo $_SESSION["PlayerDOB"]; ?>"></div>
<input name="update" type="submit" class="button" id="update" value="Update Profile">
</form>
</div>
<div id="tccol3">
</div>
</div>
<h3 class="subheader">Upload Files</h3>
<div id="bottomcontent">
<div id="bccol1">
<div class="formholder">
<h4 class="subheader">Birth Certificate</h4>
<P class="ptext">File size limited to 5MB</P>
<form action="FileUpload.php" method="post" enctype="multipart/form-data" name="FileUploadForm" id="FileUploadForm">
<label for="UploadFileField"></label>
<input type="file" name="UploadBCField" id="UploadBCField" />
<input type="submit" name="UploadButton" id="UploadButton" value="Upload" />
</form>
</div>
</div>
<div id="bccol2">
<div class="formholder">
<h4 class="subheader">Sports Physical</h4>
<P class="ptext">File size limited to 5MB</P>
<form action="FileUpload.php" method="post" enctype="multipart/form-data" name="FileUploadForm" id="FileUploadForm">
<label for="UploadFileField"></label>
<input type="file" name="UploadSPField" id="UploadSPField" />
<input type="submit" name="UploadButton" id="UploadButton" value="Upload" />
</form>
</div>
</div>
<div id="bccol3"></div>
</div>
<div id="footer" class="subheader">©2016 Chris Carver Baseball LLC</div>
</div>
</body>
</html>
Any help would be greatly appreciated. This my FIRST question on Stack Overflow, and I just started learning HTML, PHP etc. about 4 weeks ago......be gentle!
You have white space on your second line:
<?php require 'Connections/mysqlilive.php'; ?>
<?php
Between the ?> and <?php is outputting to the browser a whitespace which makes the header function inaccessible because you've already thrown a header.
Per the manual:
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.
Also note:
The HTTP status header line will always be the first sent to the client, regardless of the actual header() call being the first or not. The status may be overridden by calling header() with a new status line at any time unless the HTTP headers have already been sent.
So try:
<?php require 'Connections/mysqlilive.php';
session_start();
if(!isset($_SESSION["Username"])){
header('Location: login.php');
exit();
}
$user = $_SESSION["Username"];
$result = $conn->query("select * from user_reg where Username='$user'");
$row = $result->fetch_array(MYSQLI_BOTH);
$_SESSION["Fname"] = $row['Fname'];
$_SESSION["Lname"] = $row['Lname'];
$_SESSION["Email"] = $row['Email'];
$_SESSION["Address"] = $row['Address'];
$_SESSION["City"] = $row['City'];
$_SESSION["Zip"] = $row['Zip'];
$_SESSION["PrimaryPhone"] = $row['PrimaryPhone'];
$_SESSION["SecondaryPhone"] = $row['SecondaryPhone'];
$_SESSION["PlayerFName"] = $row['PlayerFName'];
$_SESSION["PlayerLName"] = $row['PlayerLName'];
$_SESSION["Team"] = $row['Team'];
$_SESSION["PlayerDOB"] = $row['PlayerDOB'];
$_SESSION["Waiver"] = $row['Waiver'];
$_SESSION["BirthCert"] = $row['BirthCert'];
if(isset($_POST['update'])){
$UpdateFName = $_POST['fname'];
$UpdateLName = $_POST['lname'];
$UpdateEmail = $_POST['email'];
$UpdateAddress = $_POST['address'];
$UpdateCity = $_POST['city'];
$UpdateZip = $_POST['zip'];
$UpdatePrimaryPhone = $_POST['primaryphone'];
$UpdateSecondaryPhone = $_POST['secondaryphone'];
$UpdatePlayerFName = $_POST['playerfname'];
$UpdatePlayerLName = $_POST['playerlname'];
$UpdateTeam = $_POST['team'];
$UpdatePlayerDOB = $_POST['playerdob'];
$sql = $conn->query("UPDATE user_reg SET Fname = '{$UpdateFName}', Lname = '{$UpdateLName}', Email = '{$UpdateEmail}', Address = '{$UpdateAddress}', City = '{$UpdateCity}', Zip = '{$UpdateZip}', PrimaryPhone = '{$UpdatePrimaryPhone}', SecondaryPhone = '{$UpdateSecondaryPhone}', PlayerFName = '{$UpdatePlayerFName}', PlayerLName = '{$UpdatePlayerLName}', Team = '{$UpdateTeam}', PlayerDOB = '{$UpdatePlayerDOB}' WHERE Username= '$user' ");
header("refresh:3; myvbaaccount.php");
echo("Please wait while we update your account.");
}
?>
<!doctype html>
<html>
<head>
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link href="main.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="font-awesome-4.5.0/css/font-awesome.min.css"/>
<link rel="stylesheet" type="text/css" href="dreamcodes/social_icons/tsc_social_icons.css" />
<script src="//use.edgefonts.net/black-ops-one.js"></script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="script.js"></script>
<title>Update My Account</title>
</head>
<body>
<div id="mainwrap">
<div id="headerwrap">
<div id="headertext"><h1 class="header1">valley baseball academy</h1>
<h3 class="header3">Better.Faster.Stronger.</h3></div>
<div id="headerpicture"><img src="Assets/VBA black150px.png" alt="vbablack"> <p class="phone">209.380.7721</p></div>
</div>
<div id="cssmenu">
<ul>
<li><span>Home</span></li>
<li><span>My VBA Home</span></li>
<li><span>Logout</span></li>
<li><span>Contact Us</span></li>
<li><i class="fa fa-facebook-square fa-2x"></i></li>
<li><i class="fa fa-twitter- square fa-2x"></i></li>
<li><i class="fa fa- instagram fa-2x"></i></li>
</ul>
</div>
<div id="topcontent">
<div id="tccol1">
<img class="logo" src="Assets/myvbalogo.png" alt="myvbalogo">
</div>
<div id="tccol2"><h3 class="subheader">Welcome <?php echo $_SESSION['Username']; ?>!</h3></br><h3 class="subheader">Update Your Account</h3>
<form action="" method="post" id="updateaccount">
<div class="formelement2"><input name="fname" type="text" required class="tfield3" id="fname" value="<?php echo $_SESSION["Fname"]; ?>"></div>
<div class="formelement2"><input name="lname" type="text" required class="tfield3" id="lname" value="<?php echo $_SESSION["Lname"]; ?>"></div>
<div class="formelement2"><input name="email" type="text" required class="tfield3" id="email" value="<?php echo $_SESSION["Email"]; ?>"></div>
<div class="formelement2"><input name="primaryphone" type="text" required class="tfield3" id="primaryphone" value="<?php echo $_SESSION["PrimaryPhone"]; ? >"></div>
<div class="formelement2"><input name="secondaryphone" type="text" required class="tfield3" id="secondaryphone" value="<?php echo $_SESSION["SecondaryPhone"]; ?>"></div>
<div class="formelement2"><input name="address" type="text" required class="tfield3" id="address" value="<?php echo $_SESSION["Address"]; ?>"></div>
<div class="formelement2"><input name="city" type="text" required class="tfield3" id="city" value="<?php echo $_SESSION["City"]; ?>"></div>
<div class="formelement2"><input name="zip" type="text" required class="tfield3" id="zip" value="<?php echo $_SESSION["Zip"]; ?>"></div>
<h3 class="subheader">Player Information</h3>
<div class="formelement2"><input name="playerfname" type="text" required class="tfield3" id="playerfname" value="<?php echo $_SESSION["PlayerFName"]; ?>"></div>
<div class="formelement2"><input name="playerlname" type="text" required class="tfield3" id="playerlname" value="<?php echo $_SESSION["PlayerLName"]; ?>"></div>
<div class="formelement2"><input name="team" type="text" required class="tfield3" id="team" value="<?php echo $_SESSION["Team"]; ?>"></div>
<label>Date of Birth</label><div class="formelement2"><input name="playerdob" type="text" required class="tfield3" id="playerdob" value="<?php echo $_SESSION["PlayerDOB"]; ?>"></div>
<input name="update" type="submit" class="button" id="update" value="Update Profile">
</form>
</div>
<div id="tccol3">
</div>
</div>
<h3 class="subheader">Upload Files</h3>
<div id="bottomcontent">
<div id="bccol1">
<div class="formholder">
<h4 class="subheader">Birth Certificate</h4>
<P class="ptext">File size limited to 5MB</P>
<form action="FileUpload.php" method="post" enctype="multipart/form-data" name="FileUploadForm" id="FileUploadForm">
<label for="UploadFileField"></label>
<input type="file" name="UploadBCField" id="UploadBCField" />
<input type="submit" name="UploadButton" id="UploadButton" value="Upload" />
</form>
</div>
</div>
<div id="bccol2">
<div class="formholder">
<h4 class="subheader">Sports Physical</h4>
<P class="ptext">File size limited to 5MB</P>
<form action="FileUpload.php" method="post" enctype="multipart/form-data" name="FileUploadForm" id="FileUploadForm">
<label for="UploadFileField"></label>
<input type="file" name="UploadSPField" id="UploadSPField" />
<input type="submit" name="UploadButton" id="UploadButton" value="Upload" />
</form>
</div>
</div>
<div id="bccol3"></div>
</div>
<div id="footer" class="subheader">©2016 Chris Carver Baseball LLC</div>
</div>
</body>
</html>
You also should use absolute paths for your locations and should look into using prepared statements with parameterized queries.
http://php.net/manual/en/mysqli.quickstart.prepared-statements.php
This code is viable to SQL injection, you should consider using PDO or mysqli prepared statements. Also, use die() or exit() when doing a header() cause the script continues to execute while the user is browsing another page. Also, the browser does not have to comply with the header request.
However, to answer your question you could do that with a simple GET request.
$sql = $conn->query("UPDATE ....
header("Location: profile.php?success=true");
die();
Now on the "profile.php"
if($_GET['success'] == true){
// print out the data instead of the form.
} else {
// print out other forms, etc..
}
You should exit the script after the first header(), so that it doesn't try to do a database update if the user isn't logged in.
if(!isset($_SESSION["Username"])){
header('Location: login.php');
exit();
}
My Ckeditor post variable returns as having the input I need. When I insert it into the column everything inserts, BUT the ckeditor data.
This is my function to insert:
public function SubmitReply() {
$query = <<<SQL
INSERT INTO {$this->tprefix}posts(guid,poster,content,postdate)
VALUES(:guid,:poster,:content,:postdate)
SQL;
$resource = $this->db->db->prepare( $query );
$resource->execute( array (
':guid' => $_POST['guid'],
':poster' => $_POST['poster'],
':content' => htmlspecialchars($_POST['editor1']),
':postdate' => $_POST['postdate'],
));
return $resource->rowCount();
}
And my form has:
<form id="reply" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="process" id="process" value="DEF_FORUM_SUBMIT_REPLY">
<input type="hidden" name="guid" id="guid" value="<?php DEF_TOPIC_NAME($_GET['topic']); ?>">
<input type="hidden" name="poster" id="poster" value="<?php echo $_SESSION['key']['userid']; ?>">
<input type="hidden" name="postdate" id="postdate" value="<?php echo gmdate('Y-m-d H:i:s'); ?>">
<textarea name="editor1" id="editor1" rows="10" cols="80"></textarea>
</form>
<p style="text-align:center; margin-top:10px;">
<input type="submit" class="btn btn-success" value="Post Reply" id="submit_reply">
</p>
It seems that the post for editor1 actually isn't passing now. I have no clue as to why at this point.
I'm trying to add a discount code to the paypal button, The javascript works and says the discount code is valid but isn't taking the discount off the amount when you click the buy now button to pay.
Can anyone help me please
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<p>Please click on the link to pay</p>
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="<?php echo C_OUR_EMAIL; ?>" />
<input type="hidden" name="first_name" value="<?php echo strfordisp($ofirstname); ?>" />
<input type="hidden" name="last_name" value="<?php echo strfordisp($olastname); ?>" />
<input type="hidden" name="address1" value="<?php echo strfordisp($theorder["oaddress"]); ?>" />
<input type="hidden" name="address2" value="<?php echo strfordisp($theorder["oaddress2"]); ?>" />
<input type="hidden" name="address3" value="<?php echo strfordisp($theorder["oaddress3"]); ?>" />
<input type="hidden" name="city" value="<?php echo strfordisp($theorder["otown"]); ?>">
<input type="hidden" name="zip" value="<?php echo strfordisp($theorder["opostcode"]); ?>" />
<?php
$orderdets = mysql_query("select * from c4d_orderitems where orderid='" . $_SESSION["db_order"] . "' and confirm");
$iloop = 1;
while ($orderrow = mysql_fetch_array($orderdets))
{
$itemdesc = $orderrow["itemtypedesc"];
$itemdesc .= " to " . $orderrow["dpostcode"];
$itemprice = $orderrow["cost"] + $orderrow["surcharge"] + $orderrow["insurancecost"];
?>
<input type='hidden' name="item_name_<?php echo $iloop; ?>" value='<?php echo strfordisp($itemdesc); ?>' />
<input type='hidden' name="item_number_<?php echo $iloop; ?>" value='<?php echo $orderrow["itemtype"]; ?>' />
<input type='hidden' name="amount_<?php echo $iloop; ?>" value='<?php
if ((strtoupper($ofirstname)=="PCTRENDSTEST") || (strtoupper($olastname)=="PCTRENDSTEST") || (substr($_SERVER['REMOTE_ADDR'],0,11)=="82.152.55.1"))
echo("0.01");
else echo $itemprice;
?>' />
<input type='hidden' name="baseamt_<?php echo $iloop; ?>" value='<?php if ((strtoupper($ofirstname)=="PCTRENDSTEST") || (strtoupper($olastname)=="PCTRENDSTEST") || (substr($_SERVER['REMOTE_ADDR'],0,11)=="82.152.55.1"))
echo("0.01");
else echo $itemprice;
?>' />
<input type="hidden" name="basedes_<?php echo $iloop; ?>" value="" />
<input type='hidden' name="quantity_<?php echo $iloop; ?>" value='1' />
<?
$iloop++;
}
?>
<input type="hidden" name="return" value="<?php echo C_SITE_ROOT; ?>stage7.php" />
<meta http-equiv="return" content="3;url=stage7.php" />
<input type="hidden" name="cancel-return" value="<?php echo C_SITE_ROOT; ?>order-cancel.php" />
<input type="hidden" name="notify_url" value="<?php echo C_SITE_ROOT; ?>paypal.php" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="invoice" value="<?php echo $_SESSION["db_order"]; ?>" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="no-shipping" value="1" />
<input type="hidden" name="button_subtype" value="products" />
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest" />
<input type="hidden" name="country" value="GB" />
Enter Coupon code
<input type="text" size="10" name="coupcode"; />
<input type="button" value="Check code" onclick="coupval =this.form.coupcode.value; ChkCoup();" />
<p class='fmenu'><input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"></p>
</form>
The javascript is:
var discnt = 0; // no default percent discount
var coupons = new Array ( // place to put coupon codes
"coup1", // 1st coupon value - comma seperated
"coup2", // 2nd coupon value - add all you want
"coup3" // 3rd coupon value
);
var coupdc = new Array ( 5,10,15
// place to put discounts for coupon vals
);
var coupval = "(blanket)"; // what user entered as coupon code
function ChkCoup () { // check user coupon entry
var i;
discnt = 0; // assume the worst
for (i=0; i<coupons.length; i++) {
if (coupval == coupons[i]) {
discnt = coupdc[i]; // remember the discount amt
alert ("This is a valid promo code! \n\n" + discnt + "%" +" discount now in effect.");
return;
}
}
alert ("'" + coupval + "' is not a valid promo code!");
}
function Pound (val) { // force to valid Pound amount
var str,pos,rnd=0;
if (val < .995) rnd = 1; // for old Netscape browsers
str = escape (val*1.0 + 0.005001 + rnd); // float, round, escape
pos = str.indexOf (".");
if (pos > 0) str = str.substring (rnd, pos + 3);
return str;
}
function ReadForm (obj1) { // apply the discount
var amt,des;
amt = obj1.amount_<?php echo $iloop; ?>.value*1.0; // base amount
des = obj1.basedes_<?php echo $iloop; ?>.value; // base description
if (discnt > 0) { // only if discount is active
amt = Pound (amt - (amt * discnt/100.0));
des = des + ", " + discnt + "%" + "dis, COUP = " + coupval;
}
obj1.amount.value = Pound (amt);
obj1.item_name.value = des;
}
I designed a php page if current time is greater than end time it show as closed else it show data entry form.
In that form I have several input boxes some get value from database.remain input boxes accept value less than their pair input box.else it show error and focus user to change that field how ... I tried with following code but cannot get expected result... Any solution...
<?php
include("head.php");
?>
<?php
$end = ('04:15:00 PM');
$now=date('H:i:s A');?>
<?php
$newdateformat = date("d_m_y");
$ttaerr="";
mysql_select_db($mysql_database,$bd);
$se_sql=mysql_query("select * from $newdateformat where S_No='$login_sess' ");
$row=mysql_fetch_array($se_sql);
$name=$row['S_Name'];
$address=$row['Address'];
$tamil= $row['Tamil1'];
$english=$row['English1'];
$maths= $row['Maths1']; ?>
<label> Your Name : <?php echo $login_sess;?> - <?php echo $name;?> - <?php echo $address;?> </label><br />
<?php
if($end > $now){
echo "Entry 1 Closed :";
}
else
{
?>
<form id='form1' name='form1' method='post' action='<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>'>'
<p>
<label for='tamil1'>Tamil 1 : </label>
<input name='tamil1' type='text' id='tamil1' value='<?php echo $tamil;?>' readonly="readonly" disabled="disabled"/>
</p>
<p>
<label for='tamil2'>Tamil 2 : </label>
<input name='tamil2' type='text' id='tamil2' maxlength="3" required='required' /> <?php echo $ttaerr;?>
</p>
<p>
<label for='tamil1'>English 1 : </label>
<input type='text' name='english1' id='english1' value='<?php echo $english;?>' readonly="readonly" disabled="disabled"/>
</p>
<p>
<label for='tamil2'>English 2 : </label>
<input type='text' name='english2' id='english2' required='required' maxlength="3" />
</p>
<p>
<label for='tamil1'>Maths 1 : </label>
<input type='text' name='maths1' id='maths1' value='<?php echo $maths;?>' readonly="readonly" disabled="disabled" />
</p>
<p>
<label for='tamil2'>Maths 2 : </label>
<input type='text' name='maths2' id='maths2' required='required' maxlength="3" />
</p>
<p> </p>
<p>
<input type='submit' name='submit' id='submit' value='Submit' />
</p>
</form>
<?php
if($_SERVER['REQUEST_METHOD']=="POST")
{ if(isset($_POST['tamil1'])&&isset($_POST['tamil2'])&&isset($_POST['english1'])&&isset($_POST['english2'])&&isset($_POST['maths1'])&&($_POST['maths2']))
{
$newta1=$_POST['tamil1'];
$newta2=$_POST['tamil2'];
$newen1=$_POST['english1'];
$newen2=$_POST['english2'];
$newma1=$_POST['maths1'];
$newma2=$_POST['maths2'];
if(($newta1 > $newta2)&&($newen1 > $newen2)&&($newma1 > $newma2))
{
$sql="UPDATE $newdateformat SET Time='$now',Tamil2='newta2',English2='$newen2',Maths2='$newma2' WHERE S_NO='$login_sess' and S_Name='$name'";
$result=mysql_query($sql);
if(!$result)
{
die ('Error:'.mysql_error().'<br> Back');
}
echo 'Your Record added on :'.$now.'<br> Back';
mysql_close($con);
}
else {
echo("Try Eng...");
}}
}
}
?>
</body>
</html>