Mysql Query clearing a row instead of updating - php

I have no idea why this is acting this way, I did echo out $sqll in my code and it shows all the right information but when it goes back to the page with the information it is blank.
Here is the script
<?php
include("header.php");
include("sidebar.php");
$memberon = $_GET['user'];
$getmember = mysql_query("SELECT * FROM accounts WHERE username='".$memberon."'");
$member = mysql_fetch_array($getmember);
?>
<h2>Edit User</h2>
<?php
$points = asql($_POST['points']);
$cash = asql($_POST['cash']);
$banned = asql($_POST['banned']);
$completed = asql($_POST['completed']);
$confirm= asql($_POST['confirm']);
$referral= asql($_POST['ref']);
$email= asql($_POST['email']);
$username= asql($_POST['username']);
$fname= asql($_POST['fname']);
$lname= asql($_POST['lname']);
$add= asql($_POST['address']);
$state= asql($_POST['state']);
$country= asql($_POST['country']);
$postal= asql($_POST['postal']);
$apt= asql($_POST['suite']);
$city= asql($_POST['city']);
$phone= asql($_POST['phone']);
$dob= asql($_POST['dob']);
if ($_POST['subm']) {
if($points <> $member['points'] || $cash <> $member['current_b']){
$final_report = "Checking";
print"This users balance has been updated, please input your pass code to confirm these changes <br />
<form method='post' action=''><input type='hidden' name='points' value='$points'><input type='hidden' name='cash' value='$cash'><input type='hidden' name='banned' value='$banned'><input type='hidden' name='confirm' value='$confirm'><input type='hidden' name='ref' value='$referral'><input type='hidden' name='email' value='$email'><input type='hidden' name='fname' value='$fname'><input type='hidden' name='lname' value='$lname'><input type='hidden' name='address' value='$add'><input type='hidden' name='state' value='$state'><input type='hidden' name='country' value='$country'><input type='hidden' name='postal' value='$postal'><input type='hidden' name='suite' value='$apt'><input type='hidden' name='city' value='$city'><input type='hidden' name='phone' value='$phone'><input type='hidden' name='dob' value='$dob'><input type='password' name='passcode' /><input type='submit' name='pcheck' value='Sumbit' /></form>";
}
else
{
$final_report = "";
}
if($final_report == NULL){
$updatemembers = mysql_query("UPDATE accounts SET points='$points', current_b='$cash', level='$banned', email_check='$confirm', referral='$referral', username='$username', fname='$fname', lname='$lname', email='$email', address='$add', state='$state', country='$country', postal='$postal', suite='$apt', city='$city', phone='$phone', dob='$dob' WHERE username='".$memberon."'") or die(mysql_error());
print "You Have Successfully Updated this Information";
header("Refresh: 2;url=edit.php?user=".$memberon."");
}
}
if($_POST['pcheck']){
$pchecki = asql($_POST['passcode']);
$pchecks = md5($pchecki);
$check = mysql_query("SELECT * FROM panel_access WHERE psn = '".$_SESSION['aname']."'") or die(mysql_error());
$checkar = mysql_fetch_array($check);
$final_report = "Checking.";
if($pchecks != $checkar['change_ab']){
$final_report = "That password is incorrect.";
print "".$final_report."";
header("Refresh: 2;url=edit.php?user=".$memberon."");
}
else
{
$final_report = "";
}
if($final_report == NULL){
$sqll = "UPDATE accounts SET points='".$points."', current_b='".$cash."', level='".$banned."', email_check='".$confirm."', referral='".$referral."', username='".$username."', fname='".$fname."', lname='".$lname."', email='".$email."', address='".$add."', state='".$state."', country='".$country."', postal='".$postal."', suite='".$apt."', city='".$city."', phone='".$phone."', dob='".$dob."' WHERE username='".$memberon."'";
$updatemember = mysql_query($sqll) or die(mysql_error());
print "You Have Successfully Updated this Information ".$sqll."";
header("Refresh: 2;url=edit.php?user=".$memberon."");
}
}
if(!isset($_POST['subm']) && !isset($_POST['pcheck']))
{
?>
<div class='form'>
<form action='' method='post'><input type=hidden name=subm value=1>
<div class="element">
<label for='email'>Email:</label>
<input type='text' name='email' id='email' value='<?php echo $member['email'] ?>' size='54' />
</div>
<div class="element">
<label for='username'>Username:</label>
<input type='text' name='username' id='username' value='<?php echo $member['username'] ?>' size='54' />
</div>
<div class="element">
<label for='ip'>IP Address:</label>
<input type='text' name='ip' id='ip' value='<?php echo $member['ip'] ?>' size='54' readonly='readonly' />
</div>
<div class="element">
<label for='banned'>Banned: <font color='red' size='1'><b>1=No 2=Yes</b></font></label>
<input type='text' name='banned' id='banned' value='<?php echo $member['level'] ?>' size='54' />
</div>
<div class="element">
<label for='confirm'>E-Mail Confirmed: <font color='red' size='1'>0=No 1=Yes</font></label>
<input type='text' name='confirm' id='confirm' value='<?php echo $member['email_check'] ?>' size='54' />
</div>
<div class="element">
<label for='ref'>Referral:</label>
<input type='text' name='ref' id='ref' value='<?php echo $member['referral'] ?>' size='54' />
</div>
<div class="element">
<label for='points'>Points:</label>
<input type='text' name='points' id='points' value='<?php echo $member['points'] ?>' size='54' />
</div>
<div class="element">
<label for='cash'>Cash:</label>
<input type='text' name='cash' id='cash' value='<?php echo $member['current_b'] ?>' size='54' />
</div>
<div class="element">
<label for='fname'>First Name:</label>
<input type='text' name='fname' id='fname' value='<?php echo $member['fname'] ?>' size='54' />
</div>
<div class="element">
<label for='lname'>Last Name:</label>
<input type='text' name='lname' id='lname' value='<?php echo $member['lname'] ?>' size='54' />
</div>
<div class="element">
<label for='phone'>Phone:</label>
<input type='tel' name='phone' id='phone' value='<?php echo $member['phone'] ?>' size='54' />
</div>
<div class="element">
<label for='dob'>Date of Birth:</label>
<input type='text' name='dob' id='dob' value='<?php echo $member['dob'] ?>' size='54' />
</div>
<div class="element">
<label for='address'>Address:</label>
<input type='text' name='address' id='address' value='<?php echo $member['address'] ?>' size='54' />
</div>
<div class="element">
<label for='suite'>Suite/Apt.:</label>
<input type='text' name='suite' id='suite' value='<?php echo $member['suite'] ?>' size='54' />
</div>
<div class="element">
<label for='country'>Country:</label>
<input type='text' name='country' id='country' value='<?php echo $member['country'] ?>' size='54' />
</div>
<div class="element">
<label for='state'>State:</label>
<input type='text' name='state' id='state' value='<?php echo $member['state'] ?>' size='54' />
</div>
<div class="element">
<label for='city'>City:</label>
<input type='text' name='city' id='city' value='<?php echo $member['city'] ?>' size='54' />
</div>
<div class="element">
<label for='postal'>Postal Code:</label>
<input type='text' name='postal' id='postal' value='<?php echo $member['postal'] ?>' size='54' />
</div>
<?php
print"<dl class='submit'>
<input type='submit' name='submit' id='submit' value='Submit' />
</dl>
</form>
</div> ";
}
include("footer.php");
?>
On a side note I know that mysql_query and the likes are in the process of being deprecated, I want to note that I did not write this, just doing some editing for a client, and this part is happening to be a pain in the rear.
Also its only the query in if($_POST['pcheck']) that isn't working, the first query for if($_POST['subm'] works fine

First, you have an empty string at the end. This doesn't hurt, but it has no purpose either.
You redirect the page to edit.php?user=$memberon, but $memberon isn't set when you get a POST request. You can have either GET or POST, but not both.
I would guess, you must redirect to
edit.php?user=$username

Related

Hot to append form input to appear as comment section user ID?

I am working on a comment section for a project.
I have the following php code:
<?php
echo "<form method='POST' action='".setComments($conn)."'>
<input type='hidden' name='uID' value='Anonymous'>
<input type='hidden' name='date' value='".date('Y-m-d H:i:s')."'>
<textarea name='message'></textarea><br>
<button class='submit-button' type='submit' name='commentSubmit'>Comment</button>
</form>";
getComments($conn);
?>
The setComments() and getComments() are here:
function setComments($conn) {
if(isset($_POST['commentSubmit'])){
$uID = $_POST['uID'];
$date = $_POST['date'];
$message = $_POST['message'];
$sql = "INSERT INTO commentSection (uID, date, message)
VALUES ('$uID', '$date', '$message')";
$result = $conn->query($sql);
}
}
function getComments($conn){
$sql = "SELECT * FROM commentSection";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()){
echo "<div class='comment-box'><p>";
echo $row['uID']."<br>";
echo $row['date']."<br>";
echo nl2br($row['message']);
echo "</p>
<form class='delete-form' method='POST' action='deleteComments.php'>
<input type='hidden' name='commentID' value='".$row['commentID']."'>
<button type='submit' name='commentDelete'>Delete</button>
</form>
<form class='edit-form' method='POST' action='editComment.php'>
<input type='hidden' name='commentID' value='".$row['commentID']."'>
<input type='hidden' name='uID' value='".$row['uID']."'>
<input type='hidden' name='date' value='".$row['date']."'>
<input type='hidden' name='message' value='".$row['message']."'>
<button>Edit</button>
</form>
</div>";
}
}
Now, I have created the following form element using bootstrap:
<form>
<div class="row">
<div class="col">
<input type="text" class="form-control" placeholder="First name">
</div>
</div>
</form>
How can I make it so that this form input, or the first name, value shows up here:
<input type='hidden' name='uID' value='Anonymous'>
instead of the default 'Anonymous' value?

Form not submitting , Its submit in nonwww.domain when it come with www it only reload the page

I have a form on my website it works fine with nonwww.domain. if I try with www.domain in the same site
It won't go, Its keep on rotating after captcha, refresh page with new captcha and filled form is there.
Help me solve this error
I had this form earlier its work fine in other domain
This domain is under yahoo hosting
And
I have not any reply from them
Please find the code
Is this server error
<link rel="STYLESHEET" type="text/css" href="contact.css" />
<script type='text/javascript' src='scripts/gen_validatorv31.js'></script>
<script type='text/javascript' src='scripts/fg_captcha_validator.js'></script>
<!-- Form Code Start -->
<form id='contactus' action='<?php echo $formproc->GetSelfScript(); ?>' method='post' enctype="multipart/form-data" accept-charset='UTF-8'>
<fieldset >
<legend>Contact us</legend>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<input type='hidden' name='<?php echo $formproc->GetFormIDInputName(); ?>' value='<?php echo $formproc->GetFormIDInputValue(); ?>'/>
<input type='text' class='spmhidip' name='<?php echo $formproc->GetSpamTrapInputName(); ?>' />
<div class='short_explanation'>* required fields</div>
<div><span class='error'><?php echo $formproc->GetErrorMessage(); ?></span></div>
<div class='container'>
<label for='name' >Your Full Name*: </label><br/>
<input type='text' name='name' id='name' value='<?php echo $formproc->SafeDisplay('name') ?>' maxlength="50" /><br/>
<span id='contactus_name_errorloc' class='error'></span>
</div>
<div class='container'>
<label for='email' >Email Address*:</label><br/>
<input type='text' name='email' id='email' value='<?php echo $formproc->SafeDisplay('email') ?>' maxlength="50" /><br/>
<span id='contactus_email_errorloc' class='error'></span>
</div>
<div class='container'>
<label for='message' >Message:</label><br/>
<span id='contactus_message_errorloc' class='error'></span>
<textarea rows="10" cols="50" name='message' id='message'><?php echo $formproc->SafeDisplay('message') ?></textarea>
</div>
<div class='container'>
<label for='photo' >Upload your photo:</label><br/>
<input type="file" name='photo' id='photo' /><br/>
<span id='contactus_photo_errorloc' class='error'></span>
</div>
<div class='container'>
<div><img alt='Captcha image' src='show-captcha.php?rand=1' id='scaptcha_img' /></div>
<label for='scaptcha' >Enter the code above here:</label>
<input type='text' name='scaptcha' id='scaptcha' maxlength="10" /><br/>
<span id='contactus_scaptcha_errorloc' class='error'></span>
<div class='short_explanation'>Can't read the image?
<a href='javascript: refresh_captcha_img();'>Click here to refresh</a>.</div>
</div>
<div class='container'>
<input type='submit' name='Submit' value='Submit' />
</div>
</fieldset>
</form>
<!-- client-side Form Validations:
Uses the excellent form validation script from JavaScript-coder.com-->
<script type='text/javascript'>
// <![CDATA[
var frmvalidator = new Validator("contactus");
frmvalidator.EnableOnPageErrorDisplay();
frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("name","req","Please provide your name");
frmvalidator.addValidation("email","req","Please provide your email address");
frmvalidator.addValidation("email","email","Please provide a valid email address");
frmvalidator.addValidation("message","maxlen=2048","The message is too long!(more than 2KB!)");
frmvalidator.addValidation("photo","file_extn=jpg;jpeg;gif;png;bmp","Upload images only. Supported file types are: jpg,gif,png,bmp");
frmvalidator.addValidation("scaptcha","req","Please enter the code in the image above");
document.forms['contactus'].scaptcha.validator
= new FG_CaptchaValidator(document.forms['contactus'].scaptcha,
document.images['scaptcha_img']);
function SCaptcha_Validate()
{
return document.forms['contactus'].scaptcha.validator.validate();
}
frmvalidator.setAddnlValidationFunction("SCaptcha_Validate");
function refresh_captcha_img()
{
var img = document.images['scaptcha_img'];
img.src = img.src.substring(0,img.src.lastIndexOf("?")) + "?rand="+Math.random()*1000;
}
// ]]>
</script>

Post form Data, but only one has Undefined Index error

Ive been searching for an answer, with no luck. There is one possible related post, but there is no answer avail.
Im posting form data to itself via the post action. Im then retreiving all the posted values, before sending them into a mysql table.
<?php
require_once 'config.php';
$gemBarcode = $gemSpec = $gemVar = $gemWeigh = $gemShape = $gemCut = $gemCol = $gemBrill = $gemClear = $gemTreat = $gemCertNum = $gemLWarehouse="";
$gemDesc="";
$createdDate = $modifiedDate = $gemChecked ="";
$gemW = $gemH = $gemCert =0;
$gemlength = 0;
//if form is submitted
if($_SERVER["REQUEST_METHOD"] == "POST") {
//form actions once submitted (Ie: Check the validity, and if all ok submit to server) - I will complete this later
$gemBarcode = $_POST['gemBarcode'];
$gemSpec = $_POST['gemSpec'];
$gemVar = $_POST['gemVar'];
$gemWeigh = $_POST['gemWeigh'];
$gemShape = $_POST['gemShape'];
$gemCut = $_POST['gemCut'];
$gemCol = $_POST['gemCol'];
$gemBrill = $_POST['gemBrill'];
$gemClear = $_POST['gemClear'];
$gemTreat = $_POST['gemTreat'];
$gemCertNum = $_POST['gemCertNum'];
$gemLWarehouse= $_POST['gemLWarehouse'];
$gemDesc = $_POST['gemDesc'];
$createdDate = date("Y-m-d");
$modifiedDate = date("Y-m-d");
$gemChecked = date("Y-m-d");
$gemW = $_POST['gemW'];
$gemH = $_POST['gemH'];
$gemlength = $_POST['gemlength'];
$gemCert = $_POST['gemCert'];
// $sqlstatement=$mysqli->prepare();
$sql = "INSERT INTO stockitems (gemBarcode, gemSpec, gemVar, gemWeigh, gemShape, gemCut, gemClear, gemW, gemH, gemL, gemCol, gemBrill, gemTreat, gemCert, gemCertNum, gemLWarehouse, createdDate, modifiedDate, gemChecked, gemDesc) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
if($stmt=$mysqli->prepare($sql)){
$stmt->bind_param("sssssssdddsssissssss",$Para_gemBarcode, $Para_gemSpec, $Para_gemVar, $Para_gemWeigh, $Para_gemShape, $Para_gemCut, $Para_gemClear, $Para_gemW, $Para_gemH, $Para_gemLen, $Para_gemCol, $Para_gemBrill, $Para_gemTreat, $Para_gemCert, $Para_gemCertNum, $Para_gemLWarehouse, $Para_createdDate, $Para_modifiedDate, $Para_gemChecked, $Para_gemDesc);
$Para_gemBarcode = $gemBarcode;
$Para_gemSpec = $gemSpec;
$Para_gemVar = $gemVar;
$Para_gemWeigh = $gemWeigh;
$Para_gemShape = $gemShape;
$Para_gemCut = $gemCut;
$Para_gemCol = $gemCol;
$Para_gemBrill = $gemBrill;
$Para_gemClear = $gemClear;
$Para_gemTreat = $gemTreat;
$Para_gemCertNum = $gemCertNum;
$Para_gemLWarehouse =$gemLWarehouse;
$Para_gemDesc = $gemDesc;
$Para_createdDate = $createdDate;
$Para_modifiedDate = $modifiedDate;
$Para_gemChecked = $gemChecked;
$Para_gemW = $gemW;
$Para_gemH = $gemH;
$Para_gemLen = $gemlength;
$Para_gemCert = $gemCert;
if ($stmt->execute()){
echo "Successfully executed <br>";
//WILL REDIRECT
} else {
echo "Execution Failed: <br> ".$mysqli->errno.": ".$mysqli->error;
}
}
//$stmt->close(); - any idea why this is throwing an error?
$mysqli->close();
}
?>
<!DOCTYPE HTML>
<html lang="eng">
<head>
<meta charset="UTF-8">
<title>Add New Gemstone</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<style type="text/css">
* { font-family: "arial"; }
.wrapper {
width: 90%;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="wrapper">
<form class='form-inline' action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class='row'>
<label class='col-md-2' for='gemBarcode'>Barcode</label>
<input type='number' class='form-control col-md-2' name='gemBarcode' placeholder='Barcode' required value='<?php echo $gemBarcode;?>'>
</div>
<div class='row'>
<label class='col-md-2' for='gemSpec'>Species</label>
<input type='text' class='form-control col-md-2' name='gemSpec' placeholder='Species' value='<?php echo $gemSpec;?>'>
<label class='col-md-2' for='gemVar'>Variant</label>
<input type='text' class='form-control com-md-3' name='gemVar' placeholder='Variant' value='<?php echo $gemVar;?>'>
</div>
<div class='row'>
<label class='col-md-2' for='gemWeigh'>Weight</label>
<input type='text' class='form-control col-md-2' name='gemWeigh' placeholder='Gem Weight (ct/g)' value='<?php echo $gemWeigh;?>'>
<label class='col-md-2' for='gemShape'>Shape</label>
<input type='text' class='form-control col-md-2' name='gemShape' placeholder='Shape' value='<?php echo $gemShape;?>'>
<label class='col-md-2' for='gemCut'>Cut</label>
<input type='text' class='form-control col-md-2' name='gemCut' placeholder='Cut' value='<?php echo $gemCut;?>'>
</div>
<div class='row'>
<label class='col-md-2' for='gemW'>Width</label>
<input type='number' class='form-control col-md-2' name='gemW' placeholder='Width (mm)' step='Any' value='<?php echo $gemW;?>'>
<label class='col-md-2' for='gemH'>Height</label>
<input type='number' class='form-control col-md-2' name='gemH' placeholder='Height (mm)' step='any' value='<?php echo $gemH;?>'>
<label class='col-md-2' for='gemlength'>Length</label>
<input type='number' class='form-control col-md-2' name='gemlength' placeholder='Length (mm)' step='any' value='<?php echo $gemlength; ?>'>
</div>
<div class='row'>
<label class='col-md-2' for='gemCol'>Colour</label>
<input type='text' class='form-control col-md-2' name='gemCol' placeholder='Colour' value='<?php echo $gemCol;?>'>
<label class='col-md-2' for='gemBrill'>Brilliance</label>
<input type='text' class='form-control col-md-2' name='gemBrill' placeholder='Brilliance' value='<?php echo $gemBrill;?>'>
<label class='col-md-2' for='gemClear'>Clarity</label>
<input type='text' class='form-control col-md-2' name='gemClear' placeholder='Clarity' value='<?php echo $gemClear;?>'>
</div>
<div class='row'>
<label class='col-md-2' for='gemTreat'>Enhancement</label>
<input type='text' class='form-control col-md-2' name='gemTreat' placeholder='Enhanced' value='<?php echo $gemTreat;?>'>
<div class='col'>
<label class='col-md-2' for='gemCert'>Certified</label>
<select class='form-control col-md-2' style='width=auto !important;' name='gemCert'>
<option></option>
<option value=1>Yes</option>
<option value=2>No</option>
</select>
</div>
<label class='col-md-2' for='gemCertNum'>Certificate Number</label>
<input type='text' class='form-control col-md-2' name='gemCertNum' placeholder='Certificate Number' value='<?php echo $gemCertNum;?>'>
</div>
<div class='row'>
<label class='col-md-2' for='gemLWarehouse'>Warehouse</label>
<input type='text' class='form-control col-md-2' name='gemLWarehouse' placeholder='Gem Location' value='<?php echo $gemLWarehouse;?>'>
<label class='col-md-2' for='gemDesc'>Description</label>
<input type='text' class='form-control col-md-7' name='gemDesc' placeholder='' value='<?php echo $gemDesc;?>'>
</div>
<div class='row'>
<label class='col-md-2' for='createdDate'>Created</label>
<input type='date' class='form-control col-md-2' name='createdDate' placeholder='Date Loaded' value='<?php echo $createdDate;?>'>
<label class='col-md-2' for='modifiedDate'>Modified</label>
<input type='date' class='form-control col-md-2' name='modifiedDate' placeholder='Date last Changed' value='<?php echo $modifiedDate;?>'>
<label class='col-md-2' for='gemChecked'>Checked</label>
<input type='date' class='form-control col-md-2' name='gemChecked' placeholder='Date last Checked' value='<?php echo $gemChecked;?>'>
</div>
<div class='row'>
<input type='submit' class='btn btn-primary' value='submit'>
<a href='index.php' class='btn btn-defaul'>Cancel</a>
</div>
</form>
</div>
</body>
</html>
Notes: - Please excuse the spelling - dyslexia. I had a lot of trouble with the word length, (spelling it lenght at times) but i redone these and they are all consistent. Also note: Colour is spelt right here in South Africa, Color in USA.
EDIT: The error is picked up on this line:
$gemlength = $_POST['gemlength'];
Its not a problem with my spelling, I've checked and rechecked.
I'm not sure why, but all of a sudden it started to work again, and I hadnt changed anything. Oh well, thanks anyway!

Adding a subject line to PHP form

So I've put a contact form into my site but I can't seem to add a subject line. (I'm SUPER new to PHP so I'm only about 40% sure of what I'm doing. The rest of the time I'm just learning through trial and error).
Here's what I have for the form:
<?PHP
require_once("./include/fgcontactform.php");
$formproc = new FGContactForm();
$formproc->AddRecipient('email address');
$formproc->AddSubject('Website Communication:');
$formproc->SetFormRandomKey('boQQEtSLenwppBa');
if(isset($_POST['submitted']))
{
if($formproc->ProcessForm())
{
$formproc->RedirectToURL("thank-you.php");
}
}
?>
<!-- Form Code Start -->
<form id='contactus' action='<?php echo $formproc->GetSelfScript(); ?>' method='post' accept-charset='UTF-8'>
<fieldset >
<legend>Contact us</legend>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<input type='hidden' name='<?php echo $formproc->GetFormIDInputName(); ?>' value='<?php echo $formproc->GetFormIDInputValue(); ?>'/>
<input type='text' class='spmhidip' name='<?php echo $formproc->GetSpamTrapInputName(); ?>' />
<div class='short_explanation'>* required fields</div>
<div><span class='error'><?php echo $formproc->GetErrorMessage(); ?></span></div>
<div class='container'>
<label for='name' >Your Full Name*: </label><br/>
<input type='text' name='name' id='name' value='<?php echo $formproc->SafeDisplay('name') ?>' maxlength="50" /><br/>
<span id='contactus_name_errorloc' class='error'></span>
</div>
<div class='container'>
<label for='email' >Email Address*:</label><br/>
<input type='text' name='email' id='email' value='<?php echo $formproc->SafeDisplay('email') ?>' maxlength="50" /><br/>
<span id='contactus_email_errorloc' class='error'></span>
</div>
<div class='container'>
<label for='message' >Message:</label><br/>
<span id='contactus_message_errorloc' class='error'></span>
<textarea rows="10" cols="50" name='message' id='message'><?php echo $formproc->SafeDisplay('message') ?></textarea>
</div>
<div class='container'>
<input type='submit' name='Submit' value='Submit' />
</div>
</fieldset>
</form>
I added the $formproc->AddSubject('Website Communication:'); segment but it doesn't seem to be working and I'm wondering if there's something I'm missing?
What you're really asking is how to use a specific library class that you've downloaded from the Internet! If you look into the code of the class you're including at the top (which I assume is the same as this?) then you'll see it's automatically generating a subject line here:
$this->mailer->Subject = "Contact form submission from $this->name";
The reason your AddSubject function doesn't work is because that behaviour doesn't exist within the class.
If you want to change this behaviour, you'll have to change the class. You'll want to change the above line to something like
$this->mailer->Subject = $this->getSubject();
and implement a getSubject() method, similar to the GetFromAddress() one.
Better yet, create your own mailer class! Look into the PHP mail function to get started!

sender doesnt recieve mail in popup contact form in php

I m trying pop up contact form in php. Popup form works fine.But i want the mail received by both sender and recipient. In my form recipient receives the mail whereas the sender doesn't receive the mail. Can you please help me whats wrong in the code. Here is the code
<form id='contactus' action='javascript:fg_submit_form()' method='post' accept-charset='UTF-8'>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<input type='hidden' name='<?php echo $formproc->GetFormIDInputName(); ?>' value='<?php echo $formproc->GetFormIDInputValue(); ?>'/>
<input type='text' class='spmhidip' name='<?php echo $formproc->GetSpamTrapInputName(); ?>' />
<div class='short_explanation'>* required fields</div>
<div id='fg_server_errors' class='error'></div>
<div class='container'>
<label for='name' >Your Full Name*: </label><br/>
<input type='text' name='name' id='name' value='' maxlength="50" /><br/>
<span id='contactus_name_errorloc' class='error'></span>
</div>
<div class='container'>
<label for='email' >Email Address*:</label><br/>
<input type='text' name='email' id='email' value='' maxlength="50" /><br/>
<span id='contactus_email_errorloc' class='error'></span>
</div>
<div class='container'>
<label for='message' >Message:</label><br/>
<span id='contactus_message_errorloc' class='error'></span>
<textarea rows="10" cols="50" name='message' id='message'></textarea>
</div>
<?php
require_once("./include/fgcontactform.php");
require_once("./include/captcha-creator.php");
$formproc = new FGContactForm();
$captcha = new FGCaptchaCreator('scaptcha');
$formproc->EnableCaptcha($captcha);
//1.Add your email address here.
//You can add more than one receipients.
$formproc->AddRecipient('abc#gmail.com'). $email;
$formproc->SetFormRandomKey('dz0sbNoc7mZPgXa');
if(isset($_POST['submitted']))
{
if($formproc->ProcessForm())
{
echo "success";
}
else
{
echo $formproc->GetErrorMessage();
}
}
?>
Try this:
$formproc->AddRecipient('senderEmail#gmail.com, receiverEmail#gmail.com');
$formproc->AddRecipient('abc#gmail.com'). $email;
This line looks really questionable. What are you trying to do here. If you want to send to two users you need to make two calls to the AddRecipient method

Categories