winuser2003 Posted November 24, 2009 Share Posted November 24, 2009 I have a form that I need help with. As you can see in the pictures provided the button I am talking about is the "save store" button. Right now when you click on the "save store" button, it takes all the data from the form and records it into the database. The request I am making is how do I make this one button do two functions. The first function being when the button is clicked, the data goes to the database for records (DONE ALREADY). The second function is to send a confirmation email of all the form data and notifying me that a new store has been successfully created. Lets get to the pictures and the coding... First the code... This is my administration.php file, notice it has "savestore" with an include of inc_savestore.php <?php // ---------------------------------------------------------------------- // File : administration.php // Description : store locator administration interface main script // Version : 1.0 // Created : 1/6/2007 // // Copyright (c) 2006. All rights reserved. // // ---------------------------------------------------------------------- //start session session_start(); //no cache header('Cache-Control: no-cache'); header('Pragma: no-cache'); //settings and common functions include("settings.php"); include("common.php"); include("databasewrapper.php"); include("includes/countrydropdown.php"); //allow for magic quotes if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); $_GET = array_map('stripslashes_deep', $_GET); $_COOKIE = array_map('stripslashes_deep', $_COOKIE); $_REQUEST = array_map('stripslashes_deep', $_REQUEST); } //get an action to perform if (isset($_REQUEST['pageaction'])) $pageaction = $_REQUEST['pageaction']; else $pageaction = ""; if (isset($_REQUEST['key'])) $strKey = addslashes($_REQUEST['key']); else $strKey = ""; if (isset($_REQUEST['lastrec'])) $strLastrec = $_REQUEST['lastrec']; else $strLastrec = ""; //maintain state between pages $strAdminstate = get_admin_state(0); $strNavadminstate = get_admin_state(1); $strFormadminstate = get_admin_state(2); $strAdminstatelastrec = get_admin_state(3); //security check determines whether to go to main control, login, or checklogindetails if (isset($_SESSION['securityID'])) { if ($_SESSION['securityID'] == $SecurityID) { maincontrol(); } else { login(""); } } else { if ($pageaction == "checklogindetails") { checklogindetails(); } else { if (isset($SecurityOverride)) { if ($SecurityOverride == "ON") { setsecuritysession(); maincontrol(); } else { login(""); } } } } // ---------------------------------------------------------------------- // Function : maincontrol() // Description : constructs each page of the administration interface // dynamically presenting action screens based on the // pageaction variable // Usage : maincontrol() // // ---------------------------------------------------------------------- function maincontrol() { global $pageaction; global $SetDebug, $strAdminstate, $strNavadminstate, $strFormadminstate, $strAdminstatelastrec; //build the html page to where the action screen starts pagestart(); if ($SetDebug=="ON") { print("<div class=\"debug\">ADMIN: $strAdminstate<br>NAV ADMIN: $strNavadminstate<br><br>$strFormadminstate<br><br>LAST REC: $strAdminstatelastrec</div>\n"); } startpagecontainer(); pageheader(); //set area session to allow main menu to show current area if ($pageaction == "storelist" || $pageaction == "" || $pageaction == "checklogindetails") $_SESSION['area'] = "store"; if ($pageaction == "statelist") $_SESSION['area'] = "state"; if ($pageaction == "userlist") $_SESSION['area'] = "user"; mainmenu(); startpagecontent(); switch($pageaction) { //store actions case "storelist": include("includes/inc_storelist.php"); break; case "viewstore": include("includes/inc_viewstore.php"); break; case "newstore": include("includes/inc_newstore.php"); break; case "savestore": include("includes/inc_savestore.php"); break; case "editstore": include("includes/inc_editstore.php"); break; case "updatestore": include("includes/inc_updatestore.php"); break; case "deletestore": include("includes/inc_deletestore.php"); break; case "deleteconfirmstore": include("includes/inc_deleteconfirmstore.php"); break; //user actions case "userlist": include("includes/inc_userlist.php"); break; case "viewuser": include("includes/inc_viewuser.php"); break; case "newuser": include("includes/inc_newuser.php"); break; case "saveuser": include("includes/inc_saveuser.php"); break; case "edituser": include("includes/inc_edituser.php"); break; case "updateuser": include("includes/inc_updateuser.php"); break; case "deleteuser": include("includes/inc_deleteuser.php"); break; case "deleteconfirmuser": include("includes/inc_deleteconfirmuser.php"); break; //state actions case "statelist": include("includes/inc_statelist.php"); break; case "viewstate": include("includes/inc_viewstate.php"); break; case "newstate": include("includes/inc_newstate.php"); break; case "savestate": include("includes/inc_savestate.php"); break; case "editstate": include("includes/inc_editstate.php"); break; case "updatestate": include("includes/inc_updatestate.php"); break; case "deletestate": include("includes/inc_deletestate.php"); break; case "deleteconfirmstate": include("includes/inc_deleteconfirmstate.php"); break; //default action default : include("includes/inc_storelist.php"); break; } // finish building the html page after where the action screen finishes endpagecontent(); endpagecontainer(); pageend(); } // ---------------------------------------------------------------------- // Function : checklogindetails() // Description : compares login username and password to database and // logs you in or prints the login form again with an // error message // Usage : checklogindetails() // // ---------------------------------------------------------------------- function checklogindetails() { global $SecurityID; //accept clean data $strLogin = addslashes($_REQUEST['username']); $strPassword = addslashes($_REQUEST['password']); //build sql statement $SQLstmt = "SELECT * FROM sluser WHERE username='$strLogin' AND password='$strPassword' AND recordstatus='active'"; //check database for login details $rs = dbaction($SQLstmt); if ($row=getrsrow($rs)) { //user detail found //set session variables $_SESSION['securityID'] = $SecurityID; //from settings.php $_SESSION['username'] = $row['username']; $_SESSION['userfullname'] = $row['userfullname']; $_SESSION['accesslevel'] = $row['accesslevel']; $_SESSION['area'] = "store"; maincontrol(); } else { //user detail not found display login page with error login("login details incorrect, please try again!"); } } // ---------------------------------------------------------------------- // Function : setsecuritysession() // Description : sets security related session variables if overriding // security from the settings file // Usage : setsecuritysession() // // ---------------------------------------------------------------------- function setsecuritysession() { global $SecurityID; $_SESSION['securityID'] = $SecurityID; // from settings.php $_SESSION['username'] = "override"; $_SESSION['userfullname'] = "override"; $_SESSION['accesslevel'] = "Super"; $_SESSION['area'] = "store"; } // ---------------------------------------------------------------------- // Function : login() // Description : displays a login form with optional error message // Usage : login($strError) // Arguments : $strError - login error text // // ---------------------------------------------------------------------- function login($strError) { pagestart(); print("<table width=\"100%\"><tr><td align=\"center\">\n"); print("<div id=\"logindiv\">\n"); print("<div id=\"logincontent\">\n"); print("<div id=\"loginform\">\n"); print("<div id=\"loginheading\">\n"); print("<div id=\"loginheadingtext\">Login to Store Locator</div>\n"); print("</div>\n"); print("<table cellpadding=\"0\" cellspacing=\"8\" border=\"0\">\n"); print("<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">\n"); print("<input type=\"hidden\" name=\"pageaction\" value=\"checklogindetails\">\n"); print(" <tr>\n"); print(" <td class=\"loginformtext\">Username: </td>\n"); print(" <td><input type=\"text\" name=\"username\" size=\"15\"></td>\n"); print(" </tr>\n"); print(" <tr>\n"); print(" <td class=\"loginformtext\">Password: </td>\n"); print(" <td><input type=\"password\" name=\"password\" size=\"15\"></td>\n"); print(" </tr>\n"); print(" <tr>\n"); print(" <td></td>\n"); print(" <td><input type=\"submit\" value=\"login\"></td>\n"); print(" </tr>\n"); print("</form>\n"); print("</table>\n"); print("</div>\n"); //If a login error has occured display error message if ($strError!="") { print("<div id=\"loginerror\">$strError</div>\n"); } print("</div>\n"); print("</div>\n"); print("</table>\n"); print("\n"); pageend(); } ?> Now lets look at the inc_savestore.php file <?php // ---------------------------------------------------------------------- // File : inc_savestore.php // Description : saves a store record // Version : 1.0 // Created : 1/6/2007 // // Copyright (c) 2007. All rights reserved. // // ---------------------------------------------------------------------- include("inc_security.php"); screenheading("Save store record"); //accept and cleanse fields if (isset($_REQUEST['companystoreID'])) $strCompanystoreID = addslashes($_REQUEST['companystoreID']); else $strCompanystoreID = NULL; if (isset($_REQUEST['storename'])) $strStorename = addslashes($_REQUEST['storename']); else $strStorename = NULL; if (isset($_REQUEST['address'])) $strAddress = addslashes($_REQUEST['address']); else $strAddress = NULL; if (isset($_REQUEST['city'])) $strCity = addslashes($_REQUEST['city']); else $strCity = NULL; if (isset($_REQUEST['suburb'])) $strSuburb = addslashes($_REQUEST['suburb']); else $strSuburb = NULL; if (isset($_REQUEST['stateID'])) $strStateID = addslashes($_REQUEST['stateID']); else $strStateID = NULL; if (isset($_REQUEST['country'])) $strCountry = addslashes(implode(',',$_REQUEST['country'])); else $strCountry = NULL; if (isset($_REQUEST['zippostcode'])) $strZippostcode = addslashes($_REQUEST['zippostcode']); else $strZippostcode = NULL; if (isset($_REQUEST['telephone1'])) $strTelephone1 = addslashes($_REQUEST['telephone1']); else $strTelephone1 = NULL; if (isset($_REQUEST['telephone2'])) $strTelephone2 = addslashes($_REQUEST['telephone2']); else $strTelephone2 = NULL; if (isset($_REQUEST['fax'])) $strFax = addslashes($_REQUEST['fax']); else $strFax = NULL; if (isset($_REQUEST['email'])) $strEmail = addslashes($_REQUEST['email']); else $strEmail = NULL; if (isset($_REQUEST['website'])) $strWebsite = addslashes($_REQUEST['website']); else $strWebsite = NULL; if (isset($_REQUEST['description'])) $strDescription = addslashes($_REQUEST['description']); else $strDescription = NULL; if (isset($_REQUEST['openmonday'])) $strOpenmonday = addslashes($_REQUEST['openmonday']); else $strOpenmonday = NULL; if (isset($_REQUEST['closemonday'])) $strClosemonday = addslashes($_REQUEST['closemonday']); else $strClosemonday = NULL; if (isset($_REQUEST['opentuesday'])) $strOpentuesday = addslashes($_REQUEST['opentuesday']); else $strOpentuesday = NULL; if (isset($_REQUEST['closetuesday'])) $strClosetuesday = addslashes($_REQUEST['closetuesday']); else $strClosetuesday = NULL; if (isset($_REQUEST['openwednesday'])) $strOpenwednesday = addslashes($_REQUEST['openwednesday']); else $strOpenwednesday = NULL; if (isset($_REQUEST['closewednesday'])) $strClosewednesday = addslashes($_REQUEST['closewednesday']); else $strClosewednesday = NULL; if (isset($_REQUEST['openthursday'])) $strOpenthursday = addslashes($_REQUEST['openthursday']); else $strOpenthursday = NULL; if (isset($_REQUEST['closethursday'])) $strClosethursday = addslashes($_REQUEST['closethursday']); else $strClosethursday = NULL; if (isset($_REQUEST['openfriday'])) $strOpenfriday = addslashes($_REQUEST['openfriday']); else $strOpenfriday = NULL; if (isset($_REQUEST['closefriday'])) $strClosefriday = addslashes($_REQUEST['closefriday']); else $strClosefriday = NULL; if (isset($_REQUEST['opensaturday'])) $strOpensaturday = addslashes($_REQUEST['opensaturday']); else $strOpensaturday = NULL; if (isset($_REQUEST['closesaturday'])) $strClosesaturday = addslashes($_REQUEST['closesaturday']); else $strClosesaturday = NULL; if (isset($_REQUEST['opensunday'])) $strOpensunday = addslashes($_REQUEST['opensunday']); else $strOpensunday = NULL; if (isset($_REQUEST['closesunday'])) $strClosesunday = addslashes($_REQUEST['closesunday']); else $strClosesunday = NULL; if (isset($_REQUEST['opencloseinfo'])) $strOpencloseinfo = addslashes($_REQUEST['opencloseinfo']); else $strOpencloseinfo = NULL; if (isset($_REQUEST['storemanager'])) $strStoremanager = addslashes($_REQUEST['storemanager']); else $strStoremanager = NULL; if (isset($_REQUEST['maplink'])) $strMaplink = addslashes($_REQUEST['maplink']); else $strMaplink = NULL; if (isset($_REQUEST['directions'])) $strDirections = addslashes($_REQUEST['directions']); else $strDirections = NULL; if (isset($_REQUEST['recordstatus'])) $strRecordstatus = addslashes($_REQUEST['recordstatus']); else $strRecordstatus = NULL; //generate sql statement $SQLstmt = "INSERT INTO slstore VALUES (" . "NULL, '$strCompanystoreID', '$strStorename', '$strAddress', '$strCity', " . "'$strSuburb', '$strStateID', '$strCountry', '$strZippostcode', '$strTelephone1', " . "'$strTelephone2', '$strFax', '$strEmail', '$strWebsite', '$strDescription', " . "'$strOpenmonday', '$strClosemonday', '$strOpentuesday', '$strClosetuesday', " . "'$strOpenwednesday', '$strClosewednesday', '$strOpenthursday', " . "'$strClosethursday', '$strOpenfriday', '$strClosefriday', '$strOpensaturday', " . "'$strClosesaturday', '$strOpensunday', '$strClosesunday', '$strOpencloseinfo', " . "'$strStoremanager', '$strMaplink', '$strDirections', '$strRecordstatus', " . " NULL, '{$_SESSION['username']}', NULL, '{$_SESSION['username']}'" . ")"; // execute statement if (dbaction($SQLstmt)) { print("<div id=\"messagecontainer\">\n"); printmessage("Party Room Saved"); print("</div>\n"); } ?> Now lets see some pictures... This is a view of the form: Now this is the button itself I am trying to make send an email to me: Finally this is after you click the "save store" button. The data is written to the database, but just need it to email me telling me the store has been created. Now this is probably very easy and I am not catching it right off. I appreciate you taking the time to help me out with this. Thank you. I will be googleing to coduct more research. Quote Link to comment Share on other sites More sharing options...
Deoctor Posted November 24, 2009 Share Posted November 24, 2009 i think u can write a function mail() over in the savestore.php mail <?php $from_name = "Chaitu"; $from_email = "drvirusindia@gmail.com"; $to_email = "drvirusindia@gmail.com"; $subject = "Hai"; $message = "Hai Chaitu."; $headers = "From: ".$from_name." <".$from_email.">\r\n"; $headers .= "Reply-To: ".$from_email."\r\n"; if(mail($to_email, $subject, $message, $headers, "-f".$from_email)); { echo "Mail Sent!"; } else { echo " Unable to send the mail!"; } ?> here u modify the email address and call the function after u save the records to the table.. check whether the port 21 is opened in ur server.. depending on the server capability the mail may take some time to reach the destined email id Quote Link to comment Share on other sites More sharing options...
winuser2003 Posted November 24, 2009 Author Share Posted November 24, 2009 i think u can write a function mail() over in the savestore.php mail <?php $from_name = "Chaitu"; $from_email = "drvirusindia@gmail.com"; $to_email = "drvirusindia@gmail.com"; $subject = "Hai"; $message = "Hai Chaitu."; $headers = "From: ".$from_name." <".$from_email.">\r\n"; $headers .= "Reply-To: ".$from_email."\r\n"; if(mail($to_email, $subject, $message, $headers, "-f".$from_email)); { echo "Mail Sent!"; } else { echo " Unable to send the mail!"; } ?> here u modify the email address and call the function after u save the records to the table.. check whether the port 21 is opened in ur server.. depending on the server capability the mail may take some time to reach the destined email id Is there are particular line to put this on? I am going to test this to see if it works and will let you know. I am trying to find where I call the function though and cannot find it. Is it each line like $statename, $strAddress, etc... ?? I see where you have $headers, but where would i add the rest in the script? Quote Link to comment Share on other sites More sharing options...
Anzeo Posted November 24, 2009 Share Posted November 24, 2009 I've only looked at your code quickly, but I'd guess you can call the mail function in this if block: if (dbaction($SQLstmt)) { print("<div id=\"messagecontainer\">\n"); printmessage("Party Room Saved"); print("</div>\n"); } Quote Link to comment Share on other sites More sharing options...
winuser2003 Posted November 24, 2009 Author Share Posted November 24, 2009 I've only looked at your code quickly, but I'd guess you can call the mail function in this if block: if (dbaction($SQLstmt)) { print("<div id=\"messagecontainer\">\n"); printmessage("Party Room Saved"); print("</div>\n"); } Like This? <?php // ---------------------------------------------------------------------- // File : inc_savestore.php // Description : saves a store record // Version : 1.0 // Created : 1/6/2007 // // Copyright (c) 2007. All rights reserved. // // ---------------------------------------------------------------------- include("inc_security.php"); screenheading("Save store record"); //accept and cleanse fields if (isset($_REQUEST['companystoreID'])) $strCompanystoreID = addslashes($_REQUEST['companystoreID']); else $strCompanystoreID = NULL; if (isset($_REQUEST['storename'])) $strStorename = addslashes($_REQUEST['storename']); else $strStorename = NULL; if (isset($_REQUEST['address'])) $strAddress = addslashes($_REQUEST['address']); else $strAddress = NULL; if (isset($_REQUEST['city'])) $strCity = addslashes($_REQUEST['city']); else $strCity = NULL; if (isset($_REQUEST['suburb'])) $strSuburb = addslashes($_REQUEST['suburb']); else $strSuburb = NULL; if (isset($_REQUEST['stateID'])) $strStateID = addslashes($_REQUEST['stateID']); else $strStateID = NULL; if (isset($_REQUEST['country'])) $strCountry = addslashes(implode(',',$_REQUEST['country'])); else $strCountry = NULL; if (isset($_REQUEST['zippostcode'])) $strZippostcode = addslashes($_REQUEST['zippostcode']); else $strZippostcode = NULL; if (isset($_REQUEST['telephone1'])) $strTelephone1 = addslashes($_REQUEST['telephone1']); else $strTelephone1 = NULL; if (isset($_REQUEST['telephone2'])) $strTelephone2 = addslashes($_REQUEST['telephone2']); else $strTelephone2 = NULL; if (isset($_REQUEST['fax'])) $strFax = addslashes($_REQUEST['fax']); else $strFax = NULL; if (isset($_REQUEST['email'])) $strEmail = addslashes($_REQUEST['email']); else $strEmail = NULL; if (isset($_REQUEST['website'])) $strWebsite = addslashes($_REQUEST['website']); else $strWebsite = NULL; if (isset($_REQUEST['description'])) $strDescription = addslashes($_REQUEST['description']); else $strDescription = NULL; if (isset($_REQUEST['openmonday'])) $strOpenmonday = addslashes($_REQUEST['openmonday']); else $strOpenmonday = NULL; if (isset($_REQUEST['closemonday'])) $strClosemonday = addslashes($_REQUEST['closemonday']); else $strClosemonday = NULL; if (isset($_REQUEST['opentuesday'])) $strOpentuesday = addslashes($_REQUEST['opentuesday']); else $strOpentuesday = NULL; if (isset($_REQUEST['closetuesday'])) $strClosetuesday = addslashes($_REQUEST['closetuesday']); else $strClosetuesday = NULL; if (isset($_REQUEST['openwednesday'])) $strOpenwednesday = addslashes($_REQUEST['openwednesday']); else $strOpenwednesday = NULL; if (isset($_REQUEST['closewednesday'])) $strClosewednesday = addslashes($_REQUEST['closewednesday']); else $strClosewednesday = NULL; if (isset($_REQUEST['openthursday'])) $strOpenthursday = addslashes($_REQUEST['openthursday']); else $strOpenthursday = NULL; if (isset($_REQUEST['closethursday'])) $strClosethursday = addslashes($_REQUEST['closethursday']); else $strClosethursday = NULL; if (isset($_REQUEST['openfriday'])) $strOpenfriday = addslashes($_REQUEST['openfriday']); else $strOpenfriday = NULL; if (isset($_REQUEST['closefriday'])) $strClosefriday = addslashes($_REQUEST['closefriday']); else $strClosefriday = NULL; if (isset($_REQUEST['opensaturday'])) $strOpensaturday = addslashes($_REQUEST['opensaturday']); else $strOpensaturday = NULL; if (isset($_REQUEST['closesaturday'])) $strClosesaturday = addslashes($_REQUEST['closesaturday']); else $strClosesaturday = NULL; if (isset($_REQUEST['opensunday'])) $strOpensunday = addslashes($_REQUEST['opensunday']); else $strOpensunday = NULL; if (isset($_REQUEST['closesunday'])) $strClosesunday = addslashes($_REQUEST['closesunday']); else $strClosesunday = NULL; if (isset($_REQUEST['opencloseinfo'])) $strOpencloseinfo = addslashes($_REQUEST['opencloseinfo']); else $strOpencloseinfo = NULL; if (isset($_REQUEST['storemanager'])) $strStoremanager = addslashes($_REQUEST['storemanager']); else $strStoremanager = NULL; if (isset($_REQUEST['maplink'])) $strMaplink = addslashes($_REQUEST['maplink']); else $strMaplink = NULL; if (isset($_REQUEST['directions'])) $strDirections = addslashes($_REQUEST['directions']); else $strDirections = NULL; if (isset($_REQUEST['recordstatus'])) $strRecordstatus = addslashes($_REQUEST['recordstatus']); else $strRecordstatus = NULL; //generate sql statement $SQLstmt = "INSERT INTO slstore VALUES (" . "NULL, '$strCompanystoreID', '$strStorename', '$strAddress', '$strCity', " . "'$strSuburb', '$strStateID', '$strCountry', '$strZippostcode', '$strTelephone1', " . "'$strTelephone2', '$strFax', '$strEmail', '$strWebsite', '$strDescription', " . "'$strOpenmonday', '$strClosemonday', '$strOpentuesday', '$strClosetuesday', " . "'$strOpenwednesday', '$strClosewednesday', '$strOpenthursday', " . "'$strClosethursday', '$strOpenfriday', '$strClosefriday', '$strOpensaturday', " . "'$strClosesaturday', '$strOpensunday', '$strClosesunday', '$strOpencloseinfo', " . "'$strStoremanager', '$strMaplink', '$strDirections', '$strRecordstatus', " . " NULL, '{$_SESSION['username']}', NULL, '{$_SESSION['username']}'" . ")"; // execute statement if (dbaction($SQLstmt)) } print("<div id=\"messagecontainer\">\n"); printmessage("Party Room Saved"); print("</div>\n"); } { $from_name = "Test"; $from_email = "North.pj@gmail.com"; $to_email = "North.pj@gmail.com"; $subject = "Hai"; $message = "Hai Chaitu."; $headers = "From: ".$from_name." <".$from_email.">\r\n"; $headers .= "Reply-To: ".$from_email."\r\n"; if(mail($to_email, $subject, $message, $headers, "-f".$from_email)); { echo "Mail Sent!"; } else { echo " Unable to send the mail!"; ?> Quote Link to comment Share on other sites More sharing options...
Deoctor Posted November 24, 2009 Share Posted November 24, 2009 write a function mail() giving the details which i already gave u can call the mail() at the below code if (dbaction($SQLstmt)) { print("<div id=\"messagecontainer\">\n"); printmessage("Party Room Saved"); print("</div>\n"); mail(); } i hope this will work on by the way one more thing ur server should have the port 25 opened for this to work.. or else it will not send anything Quote Link to comment Share on other sites More sharing options...
winuser2003 Posted November 24, 2009 Author Share Posted November 24, 2009 write a function mail() giving the details which i already gave u can call the mail() at the below code if (dbaction($SQLstmt)) { print("<div id=\"messagecontainer\">\n"); printmessage("Party Room Saved"); print("</div>\n"); mail(); } i hope this will work on by the way one more thing ur server should have the port 25 opened for this to work.. or else it will not send anything Well, I am trying it on the webserver now. The address is http://bapr.isgreat.org/test/store/index.php The admin address is... http://bapr.isgreat.org/test/store/administration.php this is where i am adding the code... if (dbaction($SQLstmt)) } print("<div id=\"messagecontainer\">\n"); printmessage("Party Room Saved"); print("</div>\n"); $from_name = "Test"; $from_email = "North.pj@gmail.com"; $to_email = "North.pj@gmail.com"; $subject = "Hai"; $message = "Hai Chaitu."; $headers = "From: ".$from_name." <".$from_email.">\r\n"; $headers .= "Reply-To: ".$from_email."\r\n"; if(mail($to_email, $subject, $message, $headers, "-f".$from_email)); { echo "Mail Sent!"; } else { echo " Unable to send the mail!"; } ?> Quote Link to comment Share on other sites More sharing options...
Deoctor Posted November 24, 2009 Share Posted November 24, 2009 hai i have checked out ur sever the port 25 is closed on ur machine.. ask the webadmin to open it out so that u can send the mail check the result below C:\>telnet http://bapr.isgreat.org 25Connecting To http://bapr.isgreat.org...Could not open connection to the host, on port 25: Connect failed C:\>telnet http://bapr.isgreat.org 465Connecting To http://bapr.isgreat.org...Could not open connection to the host, on port 465: Connect failed Quote Link to comment Share on other sites More sharing options...
winuser2003 Posted November 24, 2009 Author Share Posted November 24, 2009 write a function mail() giving the details which i already gave u can call the mail() at the below code if (dbaction($SQLstmt)) { print("<div id=\"messagecontainer\">\n"); printmessage("Party Room Saved"); print("</div>\n"); mail(); } i hope this will work on by the way one more thing ur server should have the port 25 opened for this to work.. or else it will not send anything Well, I am trying it on the webserver now. The address is http://bapr.isgreat.org/test/store/index.php The admin address is... http://bapr.isgreat.org/test/store/administration.php this is where i am adding the code... if (dbaction($SQLstmt)) } print("<div id=\"messagecontainer\">\n"); printmessage("Party Room Saved"); print("</div>\n"); $from_name = "Test"; $from_email = "North.pj@gmail.com"; $to_email = "North.pj@gmail.com"; $subject = "Hai"; $message = "Hai Chaitu."; $headers = "From: ".$from_name." <".$from_email.">\r\n"; $headers .= "Reply-To: ".$from_email."\r\n"; if(mail($to_email, $subject, $message, $headers, "-f".$from_email)); { echo "Mail Sent!"; } else { echo " Unable to send the mail!"; } ?> I just tried it, and seems the "Party Room Saved" message is gone, am I sticking this code in the right spot? Quote Link to comment Share on other sites More sharing options...
Deoctor Posted November 24, 2009 Share Posted November 24, 2009 the port is opened. my antivirus is blocking it out.. i hope the mail will reach to ur defined address. Quote Link to comment Share on other sites More sharing options...
winuser2003 Posted November 24, 2009 Author Share Posted November 24, 2009 the port is opened. my antivirus is blocking it out.. i hope the mail will reach to ur defined address. I know it does take a little time to get to the gmail address, my concern is do I have the code in the right spot? will the email have all the entries that I need in it? and finally, why does the message "Party Room Saved" not appear anymore after saveing a store? if you got an instant messenger we can speak through that, probably be easier... I will leave that up to you. Not a big deal. Quote Link to comment Share on other sites More sharing options...
winuser2003 Posted November 24, 2009 Author Share Posted November 24, 2009 the port is opened. my antivirus is blocking it out.. i hope the mail will reach to ur defined address. I know it does take a little time to get to the gmail address, my concern is do I have the code in the right spot? will the email have all the entries that I need in it? and finally, why does the message "Party Room Saved" not appear anymore after saveing a store? if you got an instant messenger we can speak through that, probably be easier... I will leave that up to you. Not a big deal. I tested this again, and its not saving the records now, are you sure I got this code in the right spot? I just tested it. Also the "Party Room Saved" still not showing up. Quote Link to comment Share on other sites More sharing options...
Deoctor Posted November 24, 2009 Share Posted November 24, 2009 u are just using echo the show the query right.. ur are not running the query the query should be run using the mysql_query() command give me the table structure dumb also.. Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted November 24, 2009 Share Posted November 24, 2009 looks like you are taking on a project that is well out of your hands. it's obvious you did not write the code you have provided, which is fine, but perhaps you should be starting with much smaller projects than the one you are involved in. where to place the mail function is just simple logic. think to yourself, "when should this script send an email?". on a successful db update? as well on a failed db update? probably not. etc. looking at this code, there is a very, very obvious reason it wouldn't be working .. note the closing curly brace } immediately after your opening if statement: <?php if (dbaction($SQLstmt)) } //<--what is this? print("<div id=\"messagecontainer\">\n"); printmessage("Party Room Saved"); print("</div>\n"); $from_name = "Test"; $from_email = "North.pj@gmail.com"; $to_email = "North.pj@gmail.com"; $subject = "Hai"; $message = "Hai Chaitu."; $headers = "From: ".$from_name." <".$from_email.">\r\n"; $headers .= "Reply-To: ".$from_email."\r\n"; if(mail($to_email, $subject, $message, $headers, "-f".$from_email)); { echo "Mail Sent!"; } else { echo " Unable to send the mail!"; } ?> try: <?php if (dbaction ($SQLstmt)) { print("<div id=\"messagecontainer\">\n"); printmessage("Party Room Saved"); print("</div>\n"); $from_name = "Test"; $from_email = "North.pj@gmail.com"; $to_email = "North.pj@gmail.com"; $subject = "Hai"; $message = "Hai Chaitu."; $headers = "From: ".$from_name." <".$from_email.">\r\n"; $headers .= "Reply-To: ".$from_email."\r\n"; if(mail($to_email, $subject, $message, $headers, "-f$from_email")); { echo "Mail Sent!"; } else { echo " Unable to send the mail!"; } } else { echo 'Database Error: ' . mysql_error(); } ?> Quote Link to comment Share on other sites More sharing options...
winuser2003 Posted November 25, 2009 Author Share Posted November 25, 2009 looks like you are taking on a project that is well out of your hands. it's obvious you did not write the code you have provided, which is fine, but perhaps you should be starting with much smaller projects than the one you are involved in. where to place the mail function is just simple logic. think to yourself, "when should this script send an email?". on a successful db update? as well on a failed db update? probably not. etc. looking at this code, there is a very, very obvious reason it wouldn't be working .. note the closing curly brace } immediately after your opening if statement: <?php if (dbaction($SQLstmt)) } //<--what is this? print("<div id=\"messagecontainer\">\n"); printmessage("Party Room Saved"); print("</div>\n"); $from_name = "Test"; $from_email = "North.pj@gmail.com"; $to_email = "North.pj@gmail.com"; $subject = "Hai"; $message = "Hai Chaitu."; $headers = "From: ".$from_name." <".$from_email.">\r\n"; $headers .= "Reply-To: ".$from_email."\r\n"; if(mail($to_email, $subject, $message, $headers, "-f".$from_email)); { echo "Mail Sent!"; } else { echo " Unable to send the mail!"; } ?> try: <?php if (dbaction ($SQLstmt)) { print("<div id=\"messagecontainer\">\n"); printmessage("Party Room Saved"); print("</div>\n"); $from_name = "Test"; $from_email = "North.pj@gmail.com"; $to_email = "North.pj@gmail.com"; $subject = "Hai"; $message = "Hai Chaitu."; $headers = "From: ".$from_name." <".$from_email.">\r\n"; $headers .= "Reply-To: ".$from_email."\r\n"; if(mail($to_email, $subject, $message, $headers, "-f$from_email")); { echo "Mail Sent!"; } else { echo " Unable to send the mail!"; } } else { echo 'Database Error: ' . mysql_error(); } ?> I got it guys, I actually got it the night the night before last when I caught the error why the email was not being sent. There are 3 of us writing the code, but due to the holidays I am the only left to handle it at the moment. However granted I am still learning alot and like I said in the title "probably easy" which means the obvious would be in front of me and reading the script I skim and do not go line to line. Once I analyzed line for line I caught the reason why the email was not being sent or anything. However I am picking up some tips and tricks though. I want to know more about the "Magic Quotes" function so I been reading up on that. Thank you again guys for the efforts you put in to helping me with this project. I know alot of it was obvious, its like I said I skimmed through the lines and did not catch the most obvious like I should have. Like the sane goes 2 heads are better than one. I like to be taught and shown things by the experts as well, and you all are the experts. Thank you again for everything, I still got somethings I am going to look over, but hopefully before Christmas I can have this done with. Thank You again!! Happy Thanksgiving guys!! Jeff Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.