Jump to content

DanglyWhale

New Members
  • Posts

    3
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

DanglyWhale's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you for this explanation. Do i need to install anything on my server to use PDO, or is it part of the PHP library? Lastly, do you have any insight in to my initial query: why putting too much text in a text box is causing the insert not to work? Thank you, again.
  2. Thanks for the reply, What's wrong with MYSQL? I would still need a physical database somewhere - does PDO replace that? What is PDO? I would classify myself as PHP/MYSQL retarded. I know a little, enough to understand I know nothing. I think a lot of fellow noobs would appreciate you elaborating on what PDO is, how it can be used, if it's used as well as MYSQL, etc etc. Thanks!
  3. 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); ?>
×
×
  • 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.