Jump to content

insert fails - Email Fails too, on include


wmguk

Recommended Posts

Hi

 

I've got the following script

<?php
//error_reporting(0);
  include ("connection.php");

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db($db, $con);
   
  $title = $_POST['title'];
  $firstname = $_POST['firstname'];
  $surname = $_POST['surname'];
  $address = $_POST['address'];
  $dob = $_POST['dob'];
  $tel = $_POST['tel'];
  $mob = $_POST['mob'];
  $email = $_POST['email'];
  $prefercontact = $_POST['prefercontact'];
  $nationality = $_POST['nationality'];
  $legalent = substr($_POST['legalent'], 2, 0);
  $english = substr($_POST['english'], 2, -1);  
  $convict = substr($_POST['convict'], 0, -1);  
  $convictiondetails = $_POST['convictiondetails'];
  $cvsel = $_POST['cvsel'];
  $work1 = $_POST['work1'];
  $work2 = $_POST['work2'];
  $work3 = $_POST['work3'];
  $worktype = implode(",", $_POST['worktype']);
  $ftpt = implode(",", $_POST['ftpt']);
  $avoidwork = $_POST['avoidwork'];
  $avoidemployer = $_POST['avoidemployer'];
  $datesavailable = $_POST['datesavailable'];
  $qualifications = $_POST['qualifications'];
  $experience = $_POST['experience'];
  $licences = $_POST['licences'];
  $transport = $_POST['transport'];
  $comments = $_POST['comments'];
  $searchhow = $_POST['searchhow'];
  $signature = $_POST['signature'];
  $candid = substr($surname, 0, 1);
  

//CHECK FOR EMAIL ADDRESS ALREADY USED
/* Select data from database. */
$sql="SELECT * FROM candidateinfo WHERE email='$email'"; 
$result=mysql_query($sql); 
$count=mysql_num_rows($result);

/* If email is alrady in use. */
if($count==1){
$msg = "Sorry but this email address has already been used, Please <a href='lostpassword.php?email=$email'>Click Here</a> to resend your password. ";
$err = 1;
} else {

	if($cvsel=='yes'){
	//UPLOAD FILE
	$target_path = "../cv/";
	$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
	$filename = basename( $_FILES['uploadedfile']['name']); 

			if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
					$msg = "The file ".  basename( $_FILES['uploadedfile']['name']). 
					" has been uploaded";
					$err = 2;
			} else{
					$msg = "There was an error uploading the file, please try again!";
			}

	} else {   }

//set the random id length 
$random_id_length = 10; 
$rnd_id = crypt(uniqid(rand(),1)); 
$rnd_id = strip_tags(stripslashes($rnd_id)); 
$rnd_id = str_replace(".","",$rnd_id); 
$rnd_id = strrev(str_replace("/","",$rnd_id)); 
$rnd_id = substr($rnd_id,0,$random_id_length); 

$reg_date = date("Y-m-d");
$password = $rnd_id; 

mysql_query("INSERT INTO candidateinfo (candid, password, reg_date, title, firstname, surname, dob, address, tel, mob, email, prefercontact, nationality, legalent, english, convict, convictiondetails, work1, work2, work3, worktype, ftpt, avoidwork, avoidemployer, datesavailable, qualifications, experience, licences, transport, comments, searchhow, signature) VALUES ('$candid', '$password', '$reg_date', '$title', '$firstname', '$surname', '$dob', '$address', '$tel', '$mob', '$email', '$prefercontact', '$nationality', '$legalent', '$english', '$convict', '$convictiondetails', '$work1', '$work2', '$work3', '$worktype', '$ftpt', '$avoidwork', '$avoidemployer', '$datesavailable', '$qualifications', '$experience', '$licences', '$transport', '$comments', '$searchhow', '$signature');");

}

include ("http://www.domain.co.uk/admin/scripts/candemail.php");
include ("http://www. domain.co.uk/admin/scripts/email2candidate.php");

 

for some reason nothing is entered for legalent - using $legalent = substr($_POST['legalent'], 2, 0);

im trying to remove the first 2 letters from the variable passed - it will either be XXyes or XXno

 

everything else seems ok, except I get:

 

Notice: Undefined variable: message in /var/www/vhosts/cowperrecruitment.co.uk/httpdocs/admin/scripts/candemail.php on line 19

 

$headers = "From: $title $firstname $surname  <$email>\n";
$headers .= "Reply-To: $title $firstname $surname <$email>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";

$message .= "--$mime_boundary\n";
$message .= "Content-Type: text/html; charset=UTF-8\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";
$message .= "<html>\n";
$message .= "<body>\n"; 

//START CUSTOMER TABLE

$message .= "This is the email";

# -=-=-=- FINAL BOUNDARY

$message .= "--$mime_boundary--\n\n";

 

any thoughts?

 

 

Link to comment
https://forums.phpfreaks.com/topic/130583-insert-fails-email-fails-too-on-include/
Share on other sites

  $legalent = substr($_POST['legalent'], 2, 0);

will always return empty, i assume you want something like:

  $legalent = substr($_POST['legalent'], 2);

 

as for your error...it seems like the candemail.php script is expecting a variable called $name, which is not defined anywhere. maybe you should add the following?

  $firstname = $_POST['firstname'];
  $surname = $_POST['surname'];
  $name = $firstname.' '.$surname; //Try adding this line

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.