Hi there,
I did have an old account but my login credentials have gone missing so this is a fresh account.
I have the below code which works almost perfectly... (I realise it's not encrypted yet).
My issue is, that if a user makes a long comment in the "comments" field, then none of the data is inserted in to the database, but the user is still correctly redirected to the thank you page (and a confirmation email is triggered as per the insert script sent). If the comment is short (eg "Thanks") it all gets inserted nicely...
The "Comments" field is a "text" type row with utf8_general_ci collation within my MYSQL database.
Any ideas whats going wrong here? What settings in my database or in my code should I change to allow a longer comment/text field? I always thought "text" field types supported 21k characters?! So it must be in the code, no? I wish I was better at PHP!
Thank you!
Tom
<?php
session_start();
// Database variables
$localhost = "000.000";
$username = "xxx";
$password = "xxx";
$database = "awards01";
// Establish our connection to the database
mysql_connect($localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
// Include PHPMailer for confirmation mail
require("../../utils/PHPMailer/class.phpmailer.php");
require("../../utils/PHPMailer/class.smtp.php");
$mail = new PHPMailer();
$FirstName = mysql_escape_string($_POST['FirstName']);
$LastName = mysql_escape_string($_POST['LastName']);
$Email5 = mysql_escape_string($_POST['Email']);
$Email = strtolower($Email5);
$Tel = mysql_escape_string($_POST['Tel']);
$Ref = mysql_escape_string($_POST['Ref']);
$Comments = mysql_escape_string($_POST['Comments']);
$Address1 = mysql_escape_string($_POST['Address1']);
$Address2 = mysql_escape_string($_POST['Address2']);
$Town = mysql_escape_string($_POST['Town']);
$County = mysql_escape_string($_POST['County']);
$PostCode = mysql_escape_string($_POST['PostCode']);
// To protect MySQL injection
$FirstName = stripslashes($FirstName);
$LastName = stripslashes($LastName);
$Email = stripslashes($Email);
$Tel = stripslashes($Tel);
$Ref = stripslashes($Ref);
$Comments = stripslashes($Comments);
$Address1 = stripslashes($Address1);
$Address2 = stripslashes($Address2);
$Town = stripslashes($Town);
$County = stripslashes($County);
$PostCode = stripslashes($PostCode);
// Insert into database
$PostAwards01 = "INSERT INTO details01 (`FirstName`, `LastName`, `Email`, `Tel`, `Ref`, `Comments`, `Address1`, `Address2`, `Town`, `County`, `PostCode`, `Paid`, `date`) VALUES ('$FirstName','$LastName','$Email','$Tel','$Ref','$Comments','$Address1','$Address2','$Town','$County','$PostCode','No',CURRENT_TIMESTAMP)";
mysql_query($PostAwards01);
// Create & Send email
$mail->IsSMTP();
$mail->Host = "smtp.mydomain.co.uk";
$mail->SMTPAuth = true;
$mail->Username = "
[email protected]";
$mail->Password = "xxx";
$mail->From = "
[email protected]";
$mail->FromName = "mydomain";
$mail->AddAddress($Email);
$mail->addBCC("
[email protected]");
$mail->addBCC("
[email protected]");
$mail->Subject = "Subject title here";
$mail->IsHTML(true);
$mail->AddEmbeddedImage('../img/EmailSig.jpg', 'logoimg', 'logo.jpg');
$mail->Body = "
<p>Email body</p>
";
$mail->Send();
// Redirect to thank you page
header("location:../ThankYou.php");
// Close connection
mysql_close($database);
?>