I just uploaded the files, read the wikidoc and gave it a try.
it doesnt work for a reason i ignore. (even though I guess it comes from SMTP.php - I didnt alter the file in any way)
can someone give me a hand in getting this script to work please?
Here is my code:
Code: Select all
<?php
session_start();
if (isset($id_clients))
{
require('../includes/config.php');
require('../includes/functions.tpl.php');
//store id of the client
$id = $_SESSION['id_clients'];
//get all data from the form, check if it is empty
$fname1 = (isset($_POST['fname1']))?$_POST['fname1']:'';
$lname1 = (isset($_POST['lname1']))?$_POST['lname1']:'';
$email_a = (isset($_POST['email1']))?$_POST['email1']:'';
$fname2 = (isset($_POST['fname2']))?$_POST['fname2']:'';
$lname2 = (isset($_POST['lname2']))?$_POST['lname2']:'';
$email_b = (isset($_POST['email2']))?$_POST['email2']:'';
$fname3 = (isset($_POST['fname3']))?$_POST['fname3']:'';
$lname3 = (isset($_POST['lname3']))?$_POST['lname3']:'';
$email_c = (isset($_POST['email3']))?$_POST['email3']:'';
$fname4 = (isset($_POST['fname4']))?$_POST['fname4']:'';
$lname4 = (isset($_POST['lname4']))?$_POST['lname4']:'';
$email_d = (isset($_POST['email4']))?$_POST['email4']:'';
$fname5 = (isset($_POST['fname5']))?$_POST['fname5']:'';
$lname5 = (isset($_POST['lname5']))?$_POST['lname5']:'';
$email_e = (isset($_POST['email5']))?$_POST['email5']:'';
//1st case
if(!empty($fname1) && !empty($lname1) && !empty($email_a))
{
//protect against mysql injection
$email1 = mysql_real_escape_string(htmlentities($email_a, ENT_QUOTES));
//check if email already exists
$query = (" SELECT email FROM clients WHERE email = '$email1' ");
$result = mysql_query($query) or die('Invalid query: ' . mysql_error());
$data = mysql_num_rows($result);
if ($data < 1)
{
//generates random password
$password_temp = random_password();
$password1 = md5($password_temp);
//insert into database new account: beware, EMAIL IS WRONG
$query = (" INSERT INTO clients (fname, lname, password, email, points, referral, maxgrids, gridsleft)
VALUES ('$fname1', '$lname1', '$password1', '$email1', '500', '$id', '11', '1') ");
mysql_query($query) or die('Invalid query: ' . mysql_error());
//return id of this new client, random grid, and current time
$id1 = mysql_insert_id();
//get a random grid (sorted) + convert it to an array
$sortedlist = random_draw();
$array = strtoArray($sortedlist);
$array2 = implode("-", $array);
$arraylist = substr_replace($array2,"",-1);
//gets the current time
$registration = time();
$query = (" INSERT INTO grids_clients (id_clients, grids_1, grids_2, gridnumber, timeplayed)
VALUES ('$id1', '$sortedlist', '$arraylist', '1', '$registration') ");
mysql_query($query) or die('Invalid query: ' . mysql_error());
//free memory of successive queries
mysql_free_result($result);
print "ok";
//email here
//$sendmail1 = 1;
}
//email is already in database
else
{
$email1_taken = 1;
}
}
//EMAIL TO SEND HERE
require_once "../includes/class_mailer/Swift.php";
require_once "../includes/class_mailer/Swift/Connection/SMTP.php"
//Start Swift
$smtp =& new Swift_Connection_SMTP("smtp.myserver.com");
$smtp->setUsername("admin");
$smtp->setPassword("mypassword");
$swift =& new Swift($smtp);
//Create the message
$message =& new Swift_Message("Test: title of the email", "Content: works?");
//Now check if Swift actually sends it
if ($swift->send($message, "recipient_here@email.com", "admin@myserver.com"))
{
echo "Sent";
}
else
{
echo "Failed";
}
//end 1st IF statement (line 4)
}
else
{
mysql_close();
$_SESSION['error'] = 5;
header('Location: ../errors/error.php');
}this returns a blank page AND my form is not processed (no insert in the database)...
if I use this (basically: disable the require_once[...]SMTP.php and perform a different test)
my form is processed AND I can see the message "sent" (even though nothing can be processed because I disabled the actual test)
Code: Select all
require_once "../includes/class_mailer/Swift.php";
//require_once "../includes/class_mailer/Swift/Connection/SMTP.php"
//require_once "../includes/class_mailer/Swift/Authenticator/LOGIN.php";
//Start Swift
$smtp =& new Swift_Connection_SMTP("smtp.myserver.com");
$smtp->setUsername("admin");
$smtp->setPassword("mypassword");
$swift =& new Swift($smtp);
//Create the message
$message =& new Swift_Message("Test: title of the email", "Content: works?");
//Now check if Swift actually sends it
if ($sendmail1= 1)
{
echo "Sent";
}
else
{
echo "Failed";
}Hope I gave enough info for someone to help me out
thanks!