Jump to content

nadz

Members
  • Posts

    75
  • Joined

  • Last visited

    Never

Everything posted by nadz

  1. thanks for the reply. just wondering how would i use that. im guessing $id or $row?
  2. hi, basically im making a simple registration script. ive got the script to allow users to input their name and password and email, it then logs that to my database into the fields email name password. but along with that i need to generate a random number to keep as the "id". "m doing this so that the users friends can access the users page by entering www.mysite.com/index.php?id=[id number] any help would be appreciated. if there is anyway i can make the "id" the row number in the table that would be useful too. i just need to make it so that 2 users cant have the same id numbers thankyou
  3. the spreadsheet isnt that complex but it has alot of fields for the user to input. you can see it here: http://mwfuk.org/zakatcalc.xls
  4. hi, we would really like to be able to run it online. ive found this toolonline that allows me to convert the xls file to html or php arrays but the html generated doesnt allow me to put any of the figures in. http://www.paggard.com/projects/xls.reader/ it does however look exactly like the original xls file. ps thanksfor the reply its appreciated
  5. hi, i am working for a charity here in the UK and one of our sources of donations is collecting money from muslims in the local community who are paying their annual zakat. Just a bit of background on it, zakat is compulsary on all muslims who can afford it. it basically means paying 2.5% of your earnings for the year to charitable causes eg. homeless people or charities. we have created an excel worksheet which our employees use to calculate a persons total zakat payable. now we would like people to be able to calculate their zakat themselves online via our website. so really, what we need is a way to display the excel file online and allow users to input their figures and let them work out their zakat payable online via our website. i understand this could become fairly complicated but if anyone has anysuggestions on formats we can use or software that will help us it would be well appreciated. remember, its for a good cause. Any help would be appreciated, we dont really have alot of money to spend on the website.
  6. hi, is anyone familiar with the lightbox java script at http://www.huddletogether.com/projects/lightbox/ some of my images are from an 8mp digital camera and are insane sizes. is there any way you can set a maxwidth and maxheight in the lightbox script so the image doesnt become too large. any help would be appreciated
  7. i get this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM vb1user WHERE email='n*****@googlemail.com '' at line 1 and im using this code: <?php $db_host = "mysql.t***.co.uk"; $db_user = "nextman"; $db_pwd = "*****"; $db_name = "***"; mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); $lines = file("sent.txt"); foreach($lines as $content) { list($username, $email) = explode(" : ", $content); $query = "DELETE * FROM vb1user WHERE email='$email'"; mysql_query($query) or die(mysql_error()); if($query) { echo "Deleted email address: {$email}<br>"; } } ?>
  8. ok, im having some problems. when i use the script it echos "Deleted Email address: gggg@fgfg.com" 18000 times but it doesnt actually delete the rows in the database. heres the code im using: <?php include("config.php"); mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); $lines = file("sent.txt"); foreach($lines as $content) { list($username, $email) = explode(" : ", $content); $query = mysql_query("DELETE FROM $db_table WHERE email = '{$email}'"); if($query) { echo "Deleted email address: {$email}<br>"; } else { $error = mysql_error(); echo "Error deleting email address: {$email} - {$error}"; } } ?>
  9. hi, thanks for the help chocopi ill just test that now. i was a bit confused - it was telling me it deleted all the addresses but they were still in the database. thanks again
  10. My first post was a lil dodgy, this is what it should look like. Basically ive got a list of 18000 username and email addresses in a txt file in the following form: [username] : [email] [username] : [email] [username] : [email] [username] : [email] etc etc etc The same email addresses and usernames are stored in the mysql db on my server. what im trying to do is delete all the rows in my database that match any email addresses in the txt file.for example if there is a line in the text file that says myusername : myname@myclient.com i want it to delete the mysql row that has "myname@myclient.com" in the email field. any help would be appreciated.
  11. Basically ive got a list of 18000 username and email addresses in a txt file in the following form: [username] : [username] : [username] : [username] : etc etc etc The same email addresses and usernames are stored in the mysql db on my server. what im trying to do is delete all the rows in my database that match any email addresses in the txt file. for example if there is a line in the text file that says username : myname@myclient.com i want it to delete the mysql row that has "myname@myclient.com" in the email field. any help would be appreciated.
  12. hmm, i tried that it prints the query fine, maybe i have to delete the regged emails from the array?
  13. the script grabs contacts from the users address book so it comes from one of 5 files in the /scripts directory: gmail.php hotmail.php aol.php msn.php yahoo.php if you look on line 17: include_once($scripts[$iscript]['filename']); is including the appropriate file. thanks again for your help.
  14. thanks for your help bubblegum Now ive added the code, but when i test the script it just imports the contacts as usual and includes the registered email addresses in the list it outputs. The email addresses are in: db: "users" table: "members" field: "email" there is a second field in the table called "username" this is what my code looks like now: <?php $db_host = "mysql.******.co.uk"; $db_user = "nextman"; $db_pwd = "******"; $db_name = "users"; mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); include_once("settings.php"); if (!$_POST) { include("form.php"); } else if(!$_POST['formname'] || $_POST['formname'] != "invite") { include_once($scripts[$iscript]['filename']); $login = $_POST['username']; $password = $_POST['password']; $name = $_POST['name']; $resultarray = get_contacts($login, $password); #if contacts were retreived successfully: if(is_array($resultarray)) { #the first array_shift of the result will give you the names in an array $names = array_shift($resultarray); #the second array_shift of the result will give you the emails $emails = array_shift($resultarray); $result = mysql_query($query = "SELECT email FROM members WHERE email = '{$emails}'") or trigger_error(mysql_error()."<PRE>".$query."</PRE>", E_USER_ERROR); if (mysql_num_rows($result)) { echo 'User already registered'; // email address registered } else { if (!eregi("@", $login)) { $login = $login . "@" . strtolower($iscript) . ".com"; } echo '<div align="center" style="padding:5; width:350;">'; echo '<form method="POST" action="'.$formaction .'" name="inviteform" id="inviteform"><table style="background-color:white; border:black solid thin;">'; echo '<SCRIPT LANGUAGE="JavaScript">' ."\n" .' function togglechecked(){ ' . "\n" .' for (var i = 0; i < document.inviteform.elements.length; i++) {' . "\n" .' var e = document.inviteform.elements[i];' . "\n" ." if ((e.disabled == false) && (e.name != 'allbox') && (e.type == 'checkbox')) {" ."\n" .' e.checked = document.inviteform.allbox.checked;' . "\n" .' }' . "\n" .' }' . "\n" .' }' . "\n" .' function toggleselect(){ ' . "\n" .' document.inviteform.allbox.checked = !document.inviteform.allbox.checked;' . "\n" .' togglechecked();}' . "\n" .' </SCRIPT>' . "\n"; echo "<tr bgcolor=\"#FFFFFF\"><td colspan=\"3\" align=\"center\"><h1 align=\"center\">Invite Contacts</h1>$logo</td></tr>"; echo "<tr bgcolor=\"#CCCCCC\"><td>" . "<input type=\"checkbox\" name=\"allbox\" id=\"allbox\" value=\"nothing\" onClick=\"togglechecked()\" checked>" . '</td><td><b>Name</b></td><td><b>Email</b></td></tr>'; echo '<input type="hidden" name="formname" value="invite">'; echo "<input type=\"hidden\" name=\"sender\" value=\"$login\">"; echo "<input type=\"hidden\" name=\"name\" value=\"$name\">"; $maxin = count($names); for ($i=0; $i<$maxin; ++$i) { $emails[$i] = trim($emails[$i]); if ($emails[$i]!="" && eregi("@", $emails[$i])) { $emails[$i] = strtolower($emails[$i]); echo "<tr><td>" . "<input type=\"checkbox\" name=\"addresses[]\" value=\"$emails[$i]\" checked>" . "</td><td>$names[$i]</td><td>$emails[$i]</td></tr>"; } } echo <<< _end_this <tr> <tr><td><input type="checkbox" name="allbox2" value="nothing" onClick="toggleselect()" checked></td><td><a href="javascript:toggleselect()">Select/Deselect All</a></td><td></td></tr> <td colspan="3" style="padding:4"><input name="submit" type="submit" value="Invite Selected" style="width:100%"></td> </tr> </table></form> </div> _end_this; } } else #else print out the form with the error message { switch ($resultarray) { case 1: #invalid login $formdisclaimer = "<br><b style=\"color:red\">Invalid Login</b><br>"; break; case 2: #empty username or password $formdisclaimer = "<br><b style=\"color:red\">Enter Your Username and Password</b><br>"; break; } include("form.php"); } } else if ($_POST['formname'] == "invite") { $message = file_get_contents($basedir . $slash . "email.html"); $subject = file_get_contents($basedir . $slash . "emailsubject.txt"); $addressesStr = implode(",", $_POST['addresses']); $headers = ""; if ($fromfield && $fromfield!="") { $from = $fromfield; } else { $from = trim($_POST['name']) . " <" . trim($_POST['sender']) . ">"; $headers .= "From: $from\r\n"; } $headers .= "Bcc: $addressesStr" . "\r\n"; $message = str_replace("[[[sender]]]", $_POST['name'], $message); $subject = str_replace("[[[sender]]]", $_POST['name'], $subject); $headers .= "MIME-Version: 1.0\r\n" . "Content-Type: text/html;\r\n"; if(mail ($tofield, $subject, "\r\n". $message, $headers)) $msg = "Done!"; else $msg = "Error occured"; echo <<< _end_sent <style type="text/css"> <!-- .formheading { color:black; font-size:24px; font-family:Arial, sans-serif; font-weight:bolder; } .scriptlinks a { color:blue; text-decoration:none; } --> </style> <div style="padding:5; background-color: #EEEEEE; width:350;"> <div style="width:340; border: black thin solid; background-color:white;" align="center"><h1>$msg</h1> <p>Your friends have been invited. <a href="/">Click here</a> to login </p><br><br><br></div> </div> _end_sent; } ?>
  15. Id like my invite script to check if a user is registered by cross referencing the email addresses before inviting that person. Any help would be appreciated. Import.php: <?php $db_host = "mysql.******.co.uk"; $db_user = "nextman"; $db_pwd = "*****"; $db_name = "users"; mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); include_once("settings.php"); if (!$_POST) { include("form.php"); } else if(!$_POST['formname'] || $_POST['formname'] != "invite") { include_once($scripts[$iscript]['filename']); $login = $_POST['username']; $password = $_POST['password']; $name = $_POST['name']; $resultarray = get_contacts($login, $password); #if contacts were retreived successfully: if(is_array($resultarray)) { #the first array_shift of the result will give you the names in an array $names = array_shift($resultarray); #the second array_shift of the result will give you the emails $emails = array_shift($resultarray); if (!eregi("@", $login)) { $login = $login . "@" . strtolower($iscript) . ".com"; } echo '<div align="center" style="padding:5; width:350;">'; echo '<form method="POST" action="'.$formaction .'" name="inviteform" id="inviteform"><table style="background-color:white; border:black solid thin;">'; echo '<SCRIPT LANGUAGE="JavaScript">' ."\n" .' function togglechecked(){ ' . "\n" .' for (var i = 0; i < document.inviteform.elements.length; i++) {' . "\n" .' var e = document.inviteform.elements[i];' . "\n" ." if ((e.disabled == false) && (e.name != 'allbox') && (e.type == 'checkbox')) {" ."\n" .' e.checked = document.inviteform.allbox.checked;' . "\n" .' }' . "\n" .' }' . "\n" .' }' . "\n" .' function toggleselect(){ ' . "\n" .' document.inviteform.allbox.checked = !document.inviteform.allbox.checked;' . "\n" .' togglechecked();}' . "\n" .' </SCRIPT>' . "\n"; echo "<tr bgcolor=\"#FFFFFF\"><td colspan=\"3\" align=\"center\"><h1 align=\"center\">Invite Contacts</h1>$logo</td></tr>"; echo "<tr bgcolor=\"#CCCCCC\"><td>" . "<input type=\"checkbox\" name=\"allbox\" id=\"allbox\" value=\"nothing\" onClick=\"togglechecked()\" checked>" . '</td><td><b>Name</b></td><td><b>Email</b></td></tr>'; echo '<input type="hidden" name="formname" value="invite">'; echo "<input type=\"hidden\" name=\"sender\" value=\"$login\">"; echo "<input type=\"hidden\" name=\"name\" value=\"$name\">"; $maxin = count($names); for ($i=0; $i<$maxin; ++$i) { $emails[$i] = trim($emails[$i]); if ($emails[$i]!="" && eregi("@", $emails[$i])) { $emails[$i] = strtolower($emails[$i]); echo "<tr><td>" . "<input type=\"checkbox\" name=\"addresses[]\" value=\"$emails[$i]\" checked>" . "</td><td>$names[$i]</td><td>$emails[$i]</td></tr>"; } } echo <<< _end_this <tr> <tr><td><input type="checkbox" name="allbox2" value="nothing" onClick="toggleselect()" checked></td><td><a href="javascript:toggleselect()">Select/Deselect All</a></td><td></td></tr> <td colspan="3" style="padding:4"><input name="submit" type="submit" value="Invite Selected" style="width:100%"></td> </tr> </table></form> </div> _end_this; } else #else print out the form with the error message { switch ($resultarray) { case 1: #invalid login $formdisclaimer = "<br><b style=\"color:red\">Invalid Login</b><br>"; break; case 2: #empty username or password $formdisclaimer = "<br><b style=\"color:red\">Enter Your Username and Password</b><br>"; break; } include("form.php"); } } else if ($_POST['formname'] == "invite") { $message = file_get_contents($basedir . $slash . "email.html"); $subject = file_get_contents($basedir . $slash . "emailsubject.txt"); $addressesStr = implode(",", $_POST['addresses']); $headers = ""; if ($fromfield && $fromfield!="") { $from = $fromfield; } else { $from = trim($_POST['name']) . " <" . trim($_POST['sender']) . ">"; $headers .= "From: $from\r\n"; } $headers .= "Bcc: $addressesStr" . "\r\n"; $message = str_replace("[[[sender]]]", $_POST['name'], $message); $subject = str_replace("[[[sender]]]", $_POST['name'], $subject); $headers .= "MIME-Version: 1.0\r\n" . "Content-Type: text/html;\r\n"; if(mail ($tofield, $subject, "\r\n". $message, $headers)) $msg = "Done!"; else $msg = "Error occured"; echo <<< _end_sent <style type="text/css"> <!-- .formheading { color:black; font-size:24px; font-family:Arial, sans-serif; font-weight:bolder; } .scriptlinks a { color:blue; text-decoration:none; } --> </style> <div style="padding:5; background-color: #EEEEEE; width:350;"> <div style="width:340; border: black thin solid; background-color:white;" align="center"><h1>$msg</h1> <p>Your friends have been invited. <a href="/">Click here</a> to login </p><br><br><br></div> </div> _end_sent; } ?>
  16. ok, any help is greatly appreciated at this time - im going crazy trying to figure out how to use "else" and "if " properly. id really like a script that does this: first, i have a list of email is an array like so: #if contacts were retreived successfully: if(is_array($resultarray)) { #the first array_shift of the result will give you the names in an array $names = array_shift($resultarray); #the second array_shift of the result will give you the emails $emails = array_shift($resultarray); then each email id like to check if an entry already exists in my db member table, like so: foreach($emails as $email) { $q = mysql_query("SELECT * FROM user WHERE email = '$email'") or die(mysql_error()); $rows = mysql_num_rows($q) or die(mysql_error()); if($rows > 0) { echo 'User is already a member, just send a friend request'; } with all the emails that arent already registered, id like it to continue running the script as usual which looks like this: if (!eregi("@", $login)) { $login = $login . "@" . strtolower($iscript) . ".com"; } echo '<div align="center" style="padding:5; width:350;">'; echo '<form method="POST" action="'.$formaction .'" name="inviteform" id="inviteform"><table style="background-color:white; border:black solid thin;">'; echo '<SCRIPT LANGUAGE="JavaScript">' ."\n" .' function togglechecked(){ ' . "\n" .' for (var i = 0; i < document.inviteform.elements.length; i++) {' . "\n" .' var e = document.inviteform.elements[i];' . "\n" ." if ((e.disabled == false) && (e.name != 'allbox') && (e.type == 'checkbox')) {" ."\n" .' e.checked = document.inviteform.allbox.checked;' . "\n" .' }' . "\n" .' }' . "\n" .' }' . "\n" .' function toggleselect(){ ' . "\n" .' document.inviteform.allbox.checked = !document.inviteform.allbox.checked;' . "\n" .' togglechecked();}' . "\n" .' </SCRIPT>' . "\n"; echo "<tr bgcolor=\"#FFFFFF\"><td colspan=\"3\" align=\"center\"><h1 align=\"center\">Invite Contacts</h1>$logo</td></tr>"; echo "<tr bgcolor=\"#CCCCCC\"><td>" . "<input type=\"checkbox\" name=\"allbox\" id=\"allbox\" value=\"nothing\" onClick=\"togglechecked()\" checked>" . '</td><td><b>Name</b></td><td><b>Email</b></td></tr>'; echo '<input type="hidden" name="formname" value="invite">'; echo "<input type=\"hidden\" name=\"sender\" value=\"$login\">"; echo "<input type=\"hidden\" name=\"name\" value=\"$name\">"; $maxin = count($names); for ($i=0; $i<$maxin; ++$i) { $emails[$i] = trim($emails[$i]); if ($emails[$i]!="" && eregi("@", $emails[$i])) { $emails[$i] = strtolower($emails[$i]); echo "<tr><td>" . "<input type=\"checkbox\" name=\"addresses[]\" value=\"$emails[$i]\" checked>" . "</td><td>$names[$i]</td><td>$emails[$i]</td></tr>"; } } } echo <<< _end_this <tr> <tr><td><input type="checkbox" name="allbox2" value="nothing" onClick="toggleselect()" checked></td><td><a href="javascript:toggleselect()">Select/Deselect All</a></td><td></td></tr> <td colspan="3" style="padding:4"><input name="submit" type="submit" value="Invite Selected" style="width:100%"></td> </tr> </table></form> </div> _end_this; } else #else print out the form with the error message { switch ($resultarray) { case 1: #invalid login $formdisclaimer = "<br><b style=\"color:red\">Invalid Login</b><br>"; break; case 2: #empty username or password $formdisclaimer = "<br><b style=\"color:red\">Enter Your Username and Password</b><br>"; break; } include("form.php"); } } else if ($_POST['formname'] == "invite") { $message = file_get_contents($basedir . $slash . "email.html"); $subject = file_get_contents($basedir . $slash . "emailsubject.txt"); $addressesStr = implode(",", $_POST['addresses']); $headers = ""; if ($fromfield && $fromfield!="") { $from = $fromfield; } else { $from = trim($_POST['name']) . " <" . trim($_POST['sender']) . ">"; $headers .= "From: $from\are\n"; } $headers .= "Bcc: $addressesStr" . "\are\n"; $message = str_replace("[[[sender]]]", $_POST['name'], $message); $subject = str_replace("[[[sender]]]", $_POST['name'], $subject); $headers .= "MIME-Version: 1.0\are\n" . "Content-Type: text/html;\are\n"; if(mail ($tofield, $subject, "\are\n". $message, $headers)) $msg = "Done!"; else $msg = "Error occured"; echo <<< _end_sent <style type="text/css"> <!-- .formheading { color:black; font-size:24px; font-family:Arial, sans-serif; font-weight:bolder; } .scriptlinks a { color:blue; text-decoration:none; } --> </style> <div style="padding:5; background-color: #EEEEEE; width:350;"> <div style="width:340; border: black thin solid; background-color:white;" align="center"><h1>$msg</h1> <p>Your friends have been invited. <a href="/">Click here</a> to login </p><br><br><br></div> </div> _end_sent; } ?>
  17. i think the problem is related to all these "else" and "if". maybe i put them in the wrong place?
  18. ok, this is how it usually looks: <?php $db_host = "mysql.*****.co.uk"; $db_user = "*****"; $db_pwd = "****"; $db_name = "****"; mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); include_once("settings.php"); if (!$_POST) { include("form.php"); } else if(!$_POST['formname'] || $_POST['formname'] != "invite") { include_once($scripts[$iscript]['filename']); $login = $_POST['username']; $name = $_POST['name']; $resultarray = get_contacts($login, $password); #if contacts were retreived successfully: if(is_array($resultarray)) { #the first array_shift of the result will give you the names in an array $names = array_shift($resultarray); #the second array_shift of the result will give you the emails $emails = array_shift($resultarray); if (!eregi("@", $login)) { $login = $login . "@" . strtolower($iscript) . ".com"; } echo '<div align="center" style="padding:5; width:350;">'; echo '<form method="POST" action="'.$formaction .'" name="inviteform" id="inviteform"><table style="background-color:white; border:black solid thin;">'; echo '<SCRIPT LANGUAGE="JavaScript">' ."\n" .' function togglechecked(){ ' . "\n" .' for (var i = 0; i < document.inviteform.elements.length; i++) {' . "\n" .' var e = document.inviteform.elements[i];' . "\n" ." if ((e.disabled == false) && (e.name != 'allbox') && (e.type == 'checkbox')) {" ."\n" .' e.checked = document.inviteform.allbox.checked;' . "\n" .' }' . "\n" .' }' . "\n" .' }' . "\n" .' function toggleselect(){ ' . "\n" .' document.inviteform.allbox.checked = !document.inviteform.allbox.checked;' . "\n" .' togglechecked();}' . "\n" .' </SCRIPT>' . "\n"; echo "<tr bgcolor=\"#FFFFFF\"><td colspan=\"3\" align=\"center\"><h1 align=\"center\">Invite Contacts</h1>$logo</td></tr>"; echo "<tr bgcolor=\"#CCCCCC\"><td>" . "<input type=\"checkbox\" name=\"allbox\" id=\"allbox\" value=\"nothing\" onClick=\"togglechecked()\" checked>" . '</td><td><b>Name</b></td><td><b>Email</b></td></tr>'; echo '<input type="hidden" name="formname" value="invite">'; echo "<input type=\"hidden\" name=\"sender\" value=\"$login\">"; echo "<input type=\"hidden\" name=\"name\" value=\"$name\">"; $maxin = count($names); for ($i=0; $i<$maxin; ++$i) { $emails[$i] = trim($emails[$i]); if ($emails[$i]!="" && eregi("@", $emails[$i])) { $emails[$i] = strtolower($emails[$i]); echo "<tr><td>" . "<input type=\"checkbox\" name=\"addresses[]\" value=\"$emails[$i]\" checked>" . "</td><td>$names[$i]</td><td>$emails[$i]</td></tr>"; } } echo <<< _end_this <tr> <tr><td><input type="checkbox" name="allbox2" value="nothing" onClick="toggleselect()" checked></td><td><a href="javascript:toggleselect()">Select/Deselect All</a></td><td></td></tr> <td colspan="3" style="padding:4"><input name="submit" type="submit" value="Invite Selected" style="width:100%"></td> </tr> </table></form> </div> _end_this; } else #else print out the form with the error message { switch ($resultarray) { case 1: #invalid login $formdisclaimer = "<br><b style=\"color:red\">Invalid Login</b><br>"; break; case 2: #empty username or password $formdisclaimer = "<br><b style=\"color:red\">Enter Your Username and Password</b><br>"; break; } include("form.php"); } } else if ($_POST['formname'] == "invite") { $message = file_get_contents($basedir . $slash . "email.html"); $subject = file_get_contents($basedir . $slash . "emailsubject.txt"); $addressesStr = implode(",", $_POST['addresses']); $headers = ""; if ($fromfield && $fromfield!="") { $from = $fromfield; } else { $from = trim($_POST['name']) . " <" . trim($_POST['sender']) . ">"; $headers .= "From: $from\are\n"; } $headers .= "Bcc: $addressesStr" . "\are\n"; $message = str_replace("[[[sender]]]", $_POST['name'], $message); $subject = str_replace("[[[sender]]]", $_POST['name'], $subject); $headers .= "MIME-Version: 1.0\are\n" . "Content-Type: text/html;\are\n"; if(mail ($tofield, $subject, "\are\n". $message, $headers)) $msg = "Done!"; else $msg = "Error occured"; echo <<< _end_sent <style type="text/css"> <!-- .formheading { color:black; font-size:24px; font-family:Arial, sans-serif; font-weight:bolder; } .scriptlinks a { color:blue; text-decoration:none; } --> </style> <div style="padding:5; background-color: #EEEEEE; width:350;"> <div style="width:340; border: black thin solid; background-color:white;" align="center"><h1>$msg</h1> <p>Your friends have been invited. <a href="/">Click here</a> to login </p><br><br><br></div> </div> _end_sent; } ?> and this is how im trying it: <?php $db_host = "mysql.*****.co.uk"; $db_user = "*****"; $db_pwd = "****"; $db_name = "****"; mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); include_once("settings.php"); if (!$_POST) { include("form.php"); } else if(!$_POST['formname'] || $_POST['formname'] != "invite") { include_once($scripts[$iscript]['filename']); $login = $_POST['username']; $name = $_POST['name']; $resultarray = get_contacts($login, $password); #if contacts were retreived successfully: if(is_array($resultarray)) { #the first array_shift of the result will give you the names in an array $names = array_shift($resultarray); #the second array_shift of the result will give you the emails $emails = array_shift($resultarray); foreach($emails as $email) { $q = mysql_query("SELECT * FROM user WHERE email = '$email'") or die(mysql_error()); $rows = mysql_num_rows($q) or die(mysql_error()); if($rows > 0) { // User is already a member, just send a friend request } else { if (!eregi("@", $login)) { $login = $login . "@" . strtolower($iscript) . ".com"; } echo '<div align="center" style="padding:5; width:350;">'; echo '<form method="POST" action="'.$formaction .'" name="inviteform" id="inviteform"><table style="background-color:white; border:black solid thin;">'; echo '<SCRIPT LANGUAGE="JavaScript">' ."\n" .' function togglechecked(){ ' . "\n" .' for (var i = 0; i < document.inviteform.elements.length; i++) {' . "\n" .' var e = document.inviteform.elements[i];' . "\n" ." if ((e.disabled == false) && (e.name != 'allbox') && (e.type == 'checkbox')) {" ."\n" .' e.checked = document.inviteform.allbox.checked;' . "\n" .' }' . "\n" .' }' . "\n" .' }' . "\n" .' function toggleselect(){ ' . "\n" .' document.inviteform.allbox.checked = !document.inviteform.allbox.checked;' . "\n" .' togglechecked();}' . "\n" .' </SCRIPT>' . "\n"; echo "<tr bgcolor=\"#FFFFFF\"><td colspan=\"3\" align=\"center\"><h1 align=\"center\">Invite Contacts</h1>$logo</td></tr>"; echo "<tr bgcolor=\"#CCCCCC\"><td>" . "<input type=\"checkbox\" name=\"allbox\" id=\"allbox\" value=\"nothing\" onClick=\"togglechecked()\" checked>" . '</td><td><b>Name</b></td><td><b>Email</b></td></tr>'; echo '<input type="hidden" name="formname" value="invite">'; echo "<input type=\"hidden\" name=\"sender\" value=\"$login\">"; echo "<input type=\"hidden\" name=\"name\" value=\"$name\">"; $maxin = count($names); for ($i=0; $i<$maxin; ++$i) { $emails[$i] = trim($emails[$i]); if ($emails[$i]!="" && eregi("@", $emails[$i])) { $emails[$i] = strtolower($emails[$i]); echo "<tr><td>" . "<input type=\"checkbox\" name=\"addresses[]\" value=\"$emails[$i]\" checked>" . "</td><td>$names[$i]</td><td>$emails[$i]</td></tr>"; } } } } echo <<< _end_this <tr> <tr><td><input type="checkbox" name="allbox2" value="nothing" onClick="toggleselect()" checked></td><td><a href="javascript:toggleselect()">Select/Deselect All</a></td><td></td></tr> <td colspan="3" style="padding:4"><input name="submit" type="submit" value="Invite Selected" style="width:100%"></td> </tr> </table></form> </div> _end_this; } else #else print out the form with the error message { switch ($resultarray) { case 1: #invalid login $formdisclaimer = "<br><b style=\"color:red\">Invalid Login</b><br>"; break; case 2: #empty username or password $formdisclaimer = "<br><b style=\"color:red\">Enter Your Username and Password</b><br>"; break; } include("form.php"); } } else if ($_POST['formname'] == "invite") { $message = file_get_contents($basedir . $slash . "email.html"); $subject = file_get_contents($basedir . $slash . "emailsubject.txt"); $addressesStr = implode(",", $_POST['addresses']); $headers = ""; if ($fromfield && $fromfield!="") { $from = $fromfield; } else { $from = trim($_POST['name']) . " <" . trim($_POST['sender']) . ">"; $headers .= "From: $from\are\n"; } $headers .= "Bcc: $addressesStr" . "\are\n"; $message = str_replace("[[[sender]]]", $_POST['name'], $message); $subject = str_replace("[[[sender]]]", $_POST['name'], $subject); $headers .= "MIME-Version: 1.0\are\n" . "Content-Type: text/html;\are\n"; if(mail ($tofield, $subject, "\are\n". $message, $headers)) $msg = "Done!"; else $msg = "Error occured"; echo <<< _end_sent <style type="text/css"> <!-- .formheading { color:black; font-size:24px; font-family:Arial, sans-serif; font-weight:bolder; } .scriptlinks a { color:blue; text-decoration:none; } --> </style> <div style="padding:5; background-color: #EEEEEE; width:350;"> <div style="width:340; border: black thin solid; background-color:white;" align="center"><h1>$msg</h1> <p>Your friends have been invited. <a href="/">Click here</a> to login </p><br><br><br></div> </div> _end_sent; } ?> the problem is now i just get an "invalid login" everytime i test the script.
  19. thanks ill try that today and see how far i get
  20. I have an invite script that allows my users to invite their contacts. it puts all their contacts in an array and emails each one. id like the script to split the contacts in to 2 groups - registered and unregistered so it can send an invite email to one group and a friend request to the other. any snippets of code that would help will be appreciated.
  21. wow, that was quick. suppose thats it, im gonna remember this :'( Thankyou again. Err, wheres the "solved" button?
  22. oops, ive just found one more problem. Eveything works perfect now except for one "glitch". The recipient receives my email TWICE. Any ideas why this is happening? im using this in index.php: <?php include("config.php"); mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); if (!$_POST) { include("form.php"); } else { $formbody = $_POST['formbody']; $sql = "SELECT $db_usernamefield, $db_emailfield FROM $db_table"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ $username = $row['username']; $email = $row['email']; $body = "$formbody"; $body = str_replace("[username]", $username, $body); mail($email, $emailsubject, $body, "From: $fromname <$fromemail>"); if(mail ($email, $emailsubject, $body, "From: $fromname <$fromemail>")) echo "Messages sent"; } } ?>
  23. you must be joking, all it took was one "}". Coding is frustrating. thanks alot to all of you, youve been a great help.
  24. ok, i tried using "else" and "if" like so: <?php include("config.php"); mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); if (!$_POST) { include("form.php"); } else { $formbody = $_POST['formbody']; $sql = "SELECT $db_usernamefield, $db_emailfield FROM $db_table"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ $username = $row['username']; $email = $row['email']; $body = "$formbody"; $body = str_replace("[username]", $username, $body); mail($email, $emailsubject, $body, "From: $fromname <$fromemail>"); if(mail ($email, $emailsubject, $body, "From: $fromname <$fromemail>")) echo "Messages sent"; } ?> but i get this php error on the page: Parse error: syntax error, unexpected $end in /home/.loekie/nexman/*******.co.uk/email/index.php on line 24
×
×
  • 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.