Hi iam new to php and need help:
I am trying to create a checkbox function so that if selected it will also copy the sender in on the request, code below:
<?php session_start();
require_once('db.php');
include('functions.php');
//checkLogin('1 2');
if(isset($_POST['register']))
{
if($_POST['username']!='' && $_POST['email']!='' && valid_email($_POST['email'])==TRUE && $_POST['question']!='')
{
$email= $_POST['email'];
$toEmail = "xxxx@xxxx.com";
$username= $_POST['username'];
$question= $_POST['question'];
$priority= $_POST['priority'];
$headers = 'From: [email]xxxx@xxxx.com[/email]' . "\r\n" .
'Reply-To:' . $email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$subject = "MIS Support";
$message = "Name: $username
Email: $email
Priority: $priority
Question: $question";
if(mail($toEmail, $subject, $message, $headers))
{//we show the good guy only in one case and the bad one for the rest.
$msg = 'Support Request Sent Successfully. Support will be in touch shortly.';
}
else {
$error = 'Failed to send the support email out. Please try again or contact <a href="mailto:xxxx@xxxx.com">xxxx@xxxx.com</a>';
}
}
else {
$error = 'There was an error in your data. Please make sure you filled in all the required data and you provided a valid email address';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- Body -->
<div id="bodyContainer">
<!-- Body Header -->
<div id="bodyHeader">MIS SUPPORT</div>
<!-- End Body Header-->
<!-- Body Content -->
<div id="bodyContent"><br />
<?php if(isset($msg)){ echo $msg;} else {//if we have a mesage we don't need this form again.?>
<form action="<?=$SERVER['PHP_SELF']?>" method="post">
<div style="width:80px; float:left; padding-top:5px">Name: </div>
<div><input type="text" id="username" name="username" size="32" value="<?php if(isset($POST['username'])){echo $POST['username'];}?>" /></div>
<br />
<div style="width:80px; float:left; padding-top:5px">Email: </div>
<div><input type="text" id="email" name="email" size="32" value="<?php if(isset($POST['email'])){echo $POST['email'];}?>" /></div>
<br />
<div style="width:80px; float:left; padding-top:5px">Question: </div>
<div><textarea name="question" cols="24" rows="6" id="question"><?php if(isset($POST['question'])){echo $_POST['question'];}?></textarea>
</div>
<br />
<div style="width:80px; float:left; padding-top:5px">Priority: </div>
<div><select name="priority" id="priority" style="width:218px">
<option value="Low" selected="selected">Low</option>
<option value="Medium">Medium</option>
<option value="High">High</option>
</select></div>
<div style="padding:10px 0px 0px 80px">
<p><label>
<input type="checkbox" name="checkbox" value="checkbox" />
<em>Send a copy to my email</em></label></p>
<p><label><input type="submit" name="register" value="Submit" /></label></p>
</div><br />
</form>
<? } ?>
<div style="padding:0px 0px 0px 80px; color:#FF0000"><?php if(isset($error)){ echo $error;}?></div>
<!-- End Body Content -->
</div></div>
<!-- End Body -->
<!-- Footer -->
<?php
if($_SESSION['logged_in'])
{
include("footerGlobal.php");
}
else{
include("footerNL.php");
}
?>
<!-- End Footer -->
</body>
</html>
Any help would be great!! thanks in advance!!