Jump to content

Contact form with options not properly working


mlungisi

Recommended Posts

Hi there

 

Please help, the form suppose to send email to different email address depending on enquiry option selected. Currently the form doesn?t do that and I cant seem to find or fix this issue.

 

Contact page code

 <?php
require_once('src/config.php');
$VarSecurity = new VarSecurity();

$enquiry = NULL;
$chk_Locate = FALSE;

if((isset($_GET['enquiry']) && $_GET['enquiry']=='Locate a dealer/distributor')||(isset($_POST['enquiry']) && $_POST['enquiry']=='Locate a dealer/distributor')){
$chk_Locate=TRUE;
}

if(isset($_GET['enquiry']) && $_GET['enquiry'] == 'CC'){
$query_recipients = array(array('Complaint', 'csm@mycompany.com'),
						array('Suggestion', 'csm@mycompany.com'),
						array('Compliment', 'csm@mycompany.com'));
$enquiry = '<input type="hidden" name="enquiry" id="enquiry" value="CC">';
}

else{
$query_recipients = array(array('Locate a dealer/distributor', 'sales@mycompany.com'),
						array('Technical support', 'technical@mycompany.com'),
						array('Back orders', 'backorders@mycompany.com'),
						array('Product enquiry', 'sales@mycompany.com'),
						array('Catalog request', 'sales@mycompany.com'),
						array('New customer enquiry', 'sales@mycompany.com'),
						array('Existing customers - logon', 'dealers@mycompany.com'),
						array('Existing customers - orders', 'weborder@mycompany.com'),
						array('Report web problems', 'webmaster@mycompany.com'));
}

$enquiry_options = '';
$selected_notes = '';
$item = NULL;
if(isset($_GET['item'])){
$item=$_GET['item'];
}
foreach($query_recipients as $key => $val){
if((isset($_POST['enquiry']) && $_POST['enquiry'] == $val[0])||(isset($_GET['enquiry']) && $_GET['enquiry'] == $val[0])){
	$selected = $val[0].' : '.$item;
	if($val[0]=='Existing customers - logon'||$val[0]=='Technical support'||$val[0]=='Catalog request'||$val[0]=='Product enquiry'||$val[0]=='New customer enquiry'||$val[0]=='Existing customers - orders'||$val[0]=='Catalog request'){
		$selected_notes = '<br><p>• If you are an EXISTING Radiant dealer please enter you Radiant account number so that we can correctly deal with your enquiry. Please enter your username and password for verification purposes (your login details are not sent with the enquiry). If you are already logged in you will not need to enter this information</p>
						<p>• Please enter </p><br>
						<p>Radiant only supplies to appointed distributors, and not direct to the public.</p>
						<p>However, our showrooms are open to the public daily, where you can view our product range and get assistance with your queries.</p>';
	}elseif($val[0]=='Locate a dealer/distributor'){
		$selected_notes = '<p>• Please supply your area details in the message body, as well as surrounding suburbs</p><br>';
	}
}
$enquiry_options .= '<option>'.$val[0].'</option>';
$recpt_email = $val[1];
}
if(empty($selected)){
$selected = 'Select option';
$selected_notes = '<br><p>• If you are an EXISTING Radiant dealer please enter you Radiant account number so that we can correctly deal with your enquiry. Please enter your username and password for verification purposes (your login details are not sent with the enquiry). If you are already logged in you will not need to enter this information</p><br>
						<p>Radiant only supplies to appointed distributors, and not direct to the public.</p>
						<p>However, our showrooms are open to the public daily, where you can view our product range and get assistance with your queries.</p>';
}

$cont_ref = NULL;
$ref_number = NULL;

if(isset($_POST['name'])){
$VarSecurity->protectform();

if ($Session->ID()==NULL){
	$query = @mysql_query('SELECT Accnr FROM WEB_Cust WHERE Uname="'.$_POST['dealer_username'].'" AND Pword="'.md5($_POST['dealer_password']).'" AND active=1 AND AXblocked!=2 LIMIT 0,1');
	$login = @mysql_num_rows($query);
	if($login==1){
		$cust_verify = 'Dealer is verified';
		$contact_email = 'info2@mycompany.com';
		$Session->Logout(NULL);
	} else {
		$cust_verify = 'Dealer not verfied: username/password supplied but did not match our records.';
	}
}elseif($Session->ID()!=NULL){
		$cust_verify = 'Dealer is verified';
		$contact_email = 'info2@radiant.co.za';
}else{
	$cust_verify = 'Dealer not verfied: username/password not supplied.';
}

if(isset($_POST['enquiry']) && $_POST['enquiry'] == 'CC'){
	$done = false;
	while(!$done){
		$ref_number = 'web'.strtolower(substr(str_replace(' ', '', $_POST['company']), 0, 1)).substr(md5(microtime()), 0, 5);

		$unique_query = @mysql_query('SELECT * FROM web_cms_feedback WHERE ref_number="'.$ref_number.'"');

		if(@mysql_num_rows($unique_query) == 0){
			$done = true;
		}
	}

	$insert_query = @mysql_query('INSERT INTO web_cms_feedback (Web_ref, Name, Surname, Company, Accnr, Email, Tel_cell, Enquiry, Message)
							VALUES ("'.$ref_number.'", "'.$_POST['name'].'", "'.$_POST['surname'].'", "'.$_POST['company'].'", "'.$_POST['accnr'].'", "'.$_POST['email'].'", "'.$_POST['tel'].'", "'.$_POST['enquiry'].'", "'.$_POST['message'].'")');
	$insert_data = @mysql_fetch_array($insert_query);
	$cont_ref = '<br>
				<h4>Reference: '.$ref_number.'</h4>
				You will receive an automated response to your email address shortly';
}

$_POST['recipient_email'] = $contact_email.','.$recpt_email;
if(isset($ref_number)){
	$_POST['subject'] = 'Radiant Group: '.$ref_number.': '.$_POST['enquiry'];
}else{
	$_POST['subject'] = 'Radiant Group: '.$_POST['enquiry'];
}
$_POST['sender_email'] = $_POST['email'];
$_POST['cc'] = $_POST['email'].', Radiant Group <radiant.orders@gmail.com>';
$_POST['body'] = '<p>Name: ' . $_POST['name'] . '</p>'
					. '<p>Surname: ' . $_POST['surname'] . '</p>'
					. '<p>Company: ' . $_POST['company'] . '</p>'
					. '<p>Radiant Account No.: ' . $_POST['accnr'] . '</p>'
					. '<p>Account No. verification: ' . $cust_verify . '</p>'
					. '<p>Email: ' . $_POST['email'] . '</p>'
					. '<p>Tel/cell: ' . $_POST['tel'] . '</p>'
					. $_POST['enquiry'] . ': ' . $_POST['message'];

if(Email::Send($_POST, NULL)){
	$message = 'Your feedback has been sent'.$cont_ref;
} else {
	$message = 'There was an error sending your feedback';
}
}

	$Newproducts = new NewProducts();

	global $body;
	$body = '<div class="column-310 float-left">
				<div class="block-khaki home-highlights">
					<div class="padding-10">
						<h1 class="text-white">Welcome to Radiant</h1>
						<br/>
						<p>We are committed to a brighter future by creating lighting and electrical solutions which are beautiful by design and inspired by the environment. We are certain that you will find lighting and electrical products that compliment your life space and enlighten you.</p>
					</div>
				</div>
				<div class="gap-hoz-small"></div>
				<div class="block-khaki home-newprod">
					<div class="padding-10">
						<h1 class="text-white">New Products</h1>
						</div>
						'.$Newproducts->Display().'
				</div>
			</div>';
	echo $body;
?>
        <div class="gap-vert float-left"></div>
        <div class="column-630 float-left">
        	<h1 class="text-grey">Contact feedback</h1>
            <br/>
            <p class="message"><?php echo (isset($message) ? $message : NULL); ?></p>
            <br/>
            <form id="form" action="?page=contact-feedback" method="post">
                <div class="form order-form">
                	<?php if($Session->ID()==NULL && $chk_Locate==FALSE):?>
                    <div><label>Radiant Account No.</label><div><input type="text" name="accnr" id="accnr" class="input" maxlength="100" value=" "/></div></div>
                    <p class="clear"></p>
                    <div><label>User name</label><div><input type="text" name="dealer_username" id="dealer_username" class="input dealer-input"/></div></div>
                    <p class="clear"></p>
                    <div><label>Password</label><div><input type="password" name="dealer_password" id="dealer_password" class="input dealer-input"/></div></div>
                    <p class="clear"></p>
                    <?php elseif($chk_Locate==FALSE):?>
                    <input type="hidden" name="accnr" id="accnr" class="input" maxlength="100" value="<?php echo $Session->ID();?>"/>
                    <?php endif?>
                    <p class="clear"></p><br />
                    <div><label>Name</label><div><input type="text" name="name" id="name" value="" class="input"/></div></div>
                    <p class="clear"></p>
                    <div><label>Surname</label><div><input type="text" name="surname" id="surname" value="" class="input"/></div></div>
                    <p class="clear"></p>
                    <div><label>Company</label><div><input type="text" name="company" id="company" value="" class="input"/></div></div>
                    <p class="clear"></p>
                    <div><label>Email</label><div><input type="text" name="email" id="email" class="input" maxlength="100"/></div></div>
                    <p class="clear"></p>
                    <div><label>Tel/cell</label><div><input type="text" name="tel" id="tel" class="input" maxlength="50"/></div></div>
                    <p class="clear"></p>
                    <div><label>Enquiry</label><div><select name="enquiry" id="enquiry" class="select"><option selected="selected"><?php echo $selected ?></option><?php echo $enquiry_options ?></select></div></div>
                    <p class="clear"></p>
                    <div><label>Message</label><div><textarea name="message" id="message" rows="5" cols="10" class="textarea"></textarea></div></div>
                </div>
                <div>
                <?php echo $selected_notes?>
                    <br/>
                    <?php echo $enquiry?>
                    <input type="submit" id="submit" value="submit" class="submit-khaki" onclick="javascript:return mail.Send();"/>
                    <p class="clear"></p>
                    <br/>
                </div>
            </form>
           <br />
          <p><input type="submit" value="Back" class="submit-khaki float-right" onclick="javascript:window.history.back();"/></p>
        </div> 

 

Config.php code

<?php
$db_server = '100.1001.1001.10';
$db = 'Database';
$db_username = 'username';
$db_password = 'password';

$title = 'Radiant Group (Pty) Ltd';
$env_repo = getenv('php_repository');
if(!empty($env_repo)){
$classes = $env_repo;
} else {
$classes = 'src/Classes/';
}
$pagination = array('items_per_page'=>300);
$default_page = 'Home';
$sales_email = 'weborder@mycompany.com';
$contact_email = 'info@mycompany.com';
$image_path = 'http://www.mycompany.com/src/img/email/';
?>

 

 

Link to comment
Share on other sites

For now the code sends email to: info@mycompany.com the email in config.php "$contact_email = 'info@mycompany.com';" and webmaster@mycompany.com the last email in the arrays "array('Report web problems', 'webmaster@mycompany.com'));". It doesn't matter what subject the user chooses, the emails are sent to those two email addresses.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.