PHP - Adding Email To Registering Account + Db + Config File Etc
Hey guys, Just lately I have been trying to start a specific project for myself. I started off by designing the pages etc on HTML, and then a friend of mine helped me convert them to PHP.
At the moment, when a user registers to the site, they only require to enter a Username and Password. I would like to add their email to it too, due to adding slightly extra security. It would also be used for future reasons such as sending emails out etc.
I'm not sure about adding this, I know that most likely it is going to be VERY similar to how it already is, but I couldn't seem to get it to work when I tried.
Ill give the coding which I am using for this below (the documents which I believe would need editing) :
Register.php
<?php require($_SERVER['DOCUMENT_ROOT'] . '/TruckWorld/includes/config.php'); $sOutput .= '<div id="register-body">'; if (isset($_GET['action'])) { switch (strtolower($_GET['action'])) { case 'register': // If the form was submitted lets try to create the account. if (isset($_POST['username']) && isset($_POST['password'])) { if (createAccount($_POST['username'], $_POST['password'])) { $sOutput .= '<h1>Account Created</h1><br />Your account has been created. You can now login <a href="login.php">here</a>.'; }else { // unset the action to display the registration form. unset($_GET['action']); } }else { $_SESSION['error'] = "Username and or Password was not supplied."; unset($_GET['action']); } break; } } // If the user is logged in display them a message. if (loggedIn()) { $sOutput .= '<h2>Already Registered</h2> You have already registered and are currently logged in as: ' . $_SESSION['username'] . '. <h4>Would you like to <a href="login.php?action=logout">logout</a>?</h4> <h4>Would you like to go to <a href="index.php">site index</a>?</h4>'; // If the action is not set, we want to display the registration form }elseif (!isset($_GET['action'])) { // incase there was an error // see if we have a previous username $sUsername = ""; if (isset($_POST['username'])) { $sUsername = $_POST['username']; } $sError = ""; if (isset($_SESSION['error'])) { $sError = '<span id="error">' . $_SESSION['error'] . '</span><br />'; } $sOutput .= '<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Truck World - Register</title> <!-- Core CSS - Include with every page --> <link href="css/bootstrap.min.css" rel="stylesheet"> <link href="font-awesome/css/font-awesome.css" rel="stylesheet"> <!-- SB Admin CSS - Include with every page --> <link href="css/sb-admin.css" rel="stylesheet"> </head> <body> <div align=center><img src="images/logintitle.png" alt="LoginTitle" /></div> <div class="container"> <div class="row"> <div class="col-md-4 col-md-offset-4"> <div class="login-panel panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Register To Join Truck World!</h3> </div> <div class="panel-body"> ' . $sError . ' <form name="register" method="post" action="' . $_SERVER['PHP_SELF'] . '?action=register"> <fieldset> <div class="form-group"> <input class="form-control" placeholder="Username" name="username" type="username" autofocus=""> </div> <div class="form-group"> <input class="form-control" placeholder="Password" name="password" type="password" value=""> </div> <div class="form-group"> <input class="form-control" placeholder="Email" name="email" type="email" value=""> </div> <!-- Change this to a button or input when using this as a form --> <input type="submit" class="btn btn-lg btn-success btn-block" name="submit" value="Register" /> <a href="login.php"class="btn btn-lg btn-success btn-block">Login</a> </fieldset>'; } $sOutput .= '</div> </div> </div> </div> </div> <div align=center><h5><small>Copyright - Lewis Pickles 2014 - All Rights Reserved</small></h5></div> <!-- Core Scripts - Include with every page --> <script src="js/jquery-1.10.2.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> <!-- SB Admin Scripts - Include with every page --> <script src="js/sb-admin.js"></script> </body> </html> '; // display our output. echo $sOutput; ?>Functions.php (Not sure if this would need editing, I think it might, Correct me if I'm wrong) <?php function createAccount($pUsername, $pPassword) { // First check we have data passed in. if (!empty($pUsername) && !empty($pPassword)) { $uLen = strlen($pUsername); $pLen = strlen($pPassword); // escape the $pUsername to avoid SQL Injections $eUsername = mysql_real_escape_string($pUsername); $sql = "SELECT username FROM users WHERE username = '" . $eUsername . "' LIMIT 1"; // Note the use of trigger_error instead of or die. $query = mysql_query($sql) or trigger_error("Query Failed: " . mysql_error()); // Error checks (Should be explained with the error) if ($uLen <= 4 || $uLen >= 11) { $_SESSION['error'] = "Username must be between 4 and 11 characters."; }elseif ($pLen < 6) { $_SESSION['error'] = "Password must be longer then 6 characters."; }elseif (mysql_num_rows($query) == 1) { $_SESSION['error'] = "Username already exists."; }else { // All errors passed lets // Create our insert SQL by hashing the password and using the escaped Username. $sql = "INSERT INTO users (`username`, `password`) VALUES ('" . $eUsername . "', '" . hashPassword($pPassword, SALT1, SALT2) . "');"; $query = mysql_query($sql) or trigger_error("Query Failed: " . mysql_error()); if ($query) { return true; } } } return false; } /*********** string hashPassword (string $pPassword, string $pSalt1, string $pSalt2) This will create a SHA1 hash of the password using 2 salts that the user specifies. ************/ function hashPassword($pPassword, $pSalt1="2345#$%@3e", $pSalt2="taesa%#@2%^#") { return sha1(md5($pSalt2 . $pPassword . $pSalt1)); } /*********** bool loggedIn verifies that session data is in tack and the user is valid for this session. ************/ function loggedIn() { // check both loggedin and username to verify user. if (isset($_SESSION['loggedin']) && isset($_SESSION['username'])) { return true; } return false; } /*********** bool logoutUser Log out a user by unsetting the session variable. ************/ function logoutUser() { // using unset will remove the variable // and thus logging off the user. unset($_SESSION['username']); unset($_SESSION['loggedin']); return true; } /*********** bool validateUser Attempt to verify that a username / password combination are valid. If they are it will set cookies and session data then return true. If they are not valid it simply returns false. ************/ function validateUser($pUsername, $pPassword) { // See if the username and password are valid. $sql = "SELECT username FROM users WHERE username = '" . mysql_real_escape_string($pUsername) . "' AND password = '" . hashPassword($pPassword, SALT1, SALT2) . "' LIMIT 1"; $query = mysql_query($sql) or trigger_error("Query Failed: " . mysql_error()); // If one row was returned, the user was logged in! if (mysql_num_rows($query) == 1) { $row = mysql_fetch_assoc($query); $_SESSION['username'] = $row['username']; $_SESSION['loggedin'] = true; return true; } return false; } ?>The Database for the email is as follows: Edited by Lewis2212, 06 August 2014 - 10:20 AM. Similar TutorialsI am working on a web form in PHP which accepts a Paypal Email address from the user. I need to authenticate (validate or check) if the Paypal email address entered is a valid Paypal email account. Please reply. All comments and feedback are welcomed. Thank you! where does the connection details go and in what manner order etc, server url, username, password <?php define( "DB_DSN", "); define( "DB_USERNAME", " ); define( "DB_PASSWORD", " ); define( "PAGE_SIZE", 5 ); define( "TBL_", " ); define( "TBL_", "" ); ?> I'm really embarrassed asking this.. I have two files. config.php & program.php config.php<php $max_columns = 3; ?> program.php<?php include ('config.php'); echo $max_columns; ?> I can't get the script to echo anything. I have tried... $max_columns = '3'; $max_columns = "3"; include_once include ("config.php"); include ('/path/to/file/config.php'); require .....etc. etc. Any thoughts? PLEASE, I'm going nuts here. Thanks for you patience with what must be a very trivial question for you guys I have a PHP script that is encrypted with Ion Cube. Since I don't want to violate the license, I can't modify anything in the script. The script makes calls to an XML based config file. I want to create a database to store the config data and then feed it to the encrypted script based on the referer URL that made the request. Basically, I want to "virtualize" the config XML file so I can feed the encrypted script the data I want based on the referer URL. Any ideas? I have a very simple password protection set-up on a page as a temporary measure until I can set something better up. The person I set it up for wants to be able change the Username and Password occasionally but wants me to set up a simple form which will overwrite the data in the config file (connection.php) instead of having to open the file himself (don't ask!). I have has a read round to see if there is any obvious and simple solutions but none seem as simple as I had hoped. I intend to work on a system via MySQL where there can be multiple users and passwords but as time is tight at the moment I just want to get something basic and working. The nature of the 'hidden' content is not sensitive (it is just a football clubs live commentary stream that they are hoping to get people to subscribe to) so there are no issues at this moment with security. All he needs to do is choose a new Username and Password every game and email it to the subscribers. The data that he wants to update in connection.php, via a form, is Code: [Select] $username = "user"; $password = "pass"; The code in the actual page with the log-in is Code: [Select] <?php require_once('connection.php'); if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) { ?> <h1 style="color: #FFF">Login</h1> <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p class="white_text"><label for="txtUsername">Username:</span></label> <br /> <input type="text" title="Enter your Username" name="txtUsername" /></p> <p class="white_text"><label for="txtpassword">Password:</label> <br /> <input type="password" title="Enter your password" name="txtPassword" /></p> <p><input type="submit" name="Submit" value="Login" /></p> </form> <?php } else { ?> CONTENT TO BE SHOWN................Is there a simple way of creating a form just to update those two bits in the connection.php or will I have to bite the bullet and set it up via MySQL from the off? Thanks in advance Steve This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=321126.0 I am sitting behind a firewall which blocks the http access to all popular free email providers like hotmail.com gmail.com .... The blocking is done by filtering out the domain names. So I am searching for a way to access the mailbox by a third domain e.g. mydomain123.com (which is under my control). I could imagine that there is a PHP code which can be setup on mydomain123.com which accesses the final hotmail.com mailbox by using POP3 fetches and SMTP sends. Is there such an PHP intermediate code? Peter The html Form I'm using works successfully with this php code:
<?php //check if form was sent if($_POST){ $to = 's@hmail.com'; $subject = 'Form1'; $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $headers = $name; $message .= "\r\n\r\n" . $name; if( empty($_POST["some_place"]) or $_POST['some_place'] != "glory" ) { header("HTTP/1.0 403 Forbidden"); }else{ mail( $to, $subject, $message, $email, $headers ); } header('Location: https://.......com'); exit; } ?>
The problem is that when the email is received it shows the (from) email address to be my domain account user name @ the server name, like this: Any help or suggested remedy will be appreciated To me it is logical to store config data such as site name, meta, etc in a php file rather than storing ina table in mysql database. This will reduce the number of calls to the mysql database, as these are key parameters and needed in every page. But, a well-developed CMS like Wordpress uses a mysql table to store such basic data. What is your idea? Ain't it better to reduce mysql loads? This is my first post on your forums. I've some problems with a registration form that I've been trying to work out for 2+ days now, asking about it here is a last resort - I have a config.php file located at config/config.php there's a register.php file in the sites root directory and a includes/form_handlers/register.php
My config.php file is: <?php ob_start(); session_start(); $timezone = date_default_timezone_set("America/Cancun"); $servername = "localhost"; $username = "root"; $password = ""; $database = "social"; $conn = mysqli_connect($servername, $username, $password, $database); if (mysqli_connect_error()) { echo "Failed to connect: " . mysqli_connect_error(); } ?> This is my register.php file: <?php require 'config/config.php'; require 'includes/form_handlers/register.php'; ?> <!-- REMOVED THE <HEAD> SECTION --> <body class="login-img3-body"> <div class="container"> <form class="login-form" action="includes/form_handlers/register.php" method="POST"> <div class="login-wrap"> <p class="login-img"><i class="icon_lock_alt"></i></p> <div class="input-group"> <span class="input-group-addon"><i class="icon_profile"></i></span> <input type="text" class="form-control" name="fname" placeholder="First Name" value="<?php if(isset($_SESSION['fname'])) { echo $_SESSION['fname']; } ?>" required> <br> <?php if(in_array("Your first name must be 2-50 characters long.<br>", $error_array)) echo "<span style='color: #AD0303;'>Your first name must be 2-50 characters long.</span><br>"; ?> </div> <div class="input-group"> <span class="input-group-addon"><i class="icon_profile"></i></span> <input type="text" class="form-control" name="lname" placeholder="Last Name" value="<?php if(isset($_SESSION['lname'])) { echo $_SESSION['lname']; } ?>" required> <br> <?php if(in_array("Your last name must be 2-50 characters long.<br>", $error_array)) echo "<span style='color: #AD0303;'>Your last name must be 2-50 characters long.</span><br>"; ?> </div> <div class="input-group"> <span class="input-group-addon"><i class="icon_mail_alt"></i></span> <input type="text" class="form-control" name="email" placeholder="Email" value="<?php if(isset($_SESSION['email'])) { echo $_SESSION['email']; } ?>" required> </div> <div class="input-group"> <span class="input-group-addon"><i class="icon_mail_alt"></i></span> <input type="text" class="form-control" name="email2" placeholder="Confirm Email" value="<?php if(isset($_SESSION['email2'])) { echo $_SESSION['email2']; } ?>" required> <br> <?php if(in_array("Email already in use<br>", $error_array)) echo "<span style='color: #AD0303;'>Email already in use</span><br>"; else if(in_array("Invalid Email<br>", $error_array)) echo "<span style='color: #AD0303;'>Invalid Email</span><br>"; else if(in_array("Emails don't match<br>", $error_array)) echo "<span style='color: #AD0303;'>Emails don't match</span><br>"; ?> </div> <div class="input-group"> <span class="input-group-addon"><i class="icon_key_alt"></i></span> <input type="password" class="form-control" name="pwd" placeholder="Password" required> </div> <div class="input-group"> <span class="input-group-addon"><i class="icon_key_alt"></i></span> <input type="password" class="form-control" name="pwd2" placeholder="Confirm Password" required> <br> <?php if(in_array("Your passwords don't match.<br>", $error_array)) echo "<span style='color: #AD0303;'>Your passwords don't match.</span><br>"; else if(in_array("Your password must contain English characters or numbers.<br>", $error_array)) echo "<span style='color: #AD0303;'>Your password must contain English characters or numbers.</span><br>"; else if(in_array("Your password must be 5-30 characters long.<br>", $error_array)) echo "<span style='color: #AD0303;'>Your password must be 5-30 characters long.</span><br>"; ?> </div> <input class="btn btn-info btn-lg btn-block" type="submit" name="register" value="Register"> </div> <?php if(in_array("<span style='color: #14C800;'>You're all set! Go ahead and login!</span><br>", $error_array)) echo "<span style='color: #14C800;'>You're all set! Go ahead and login!</span><br>"; ?> </form> </div> </body> </html> and my includes/form_handlers/register.php file: <?php //error variables $fname = ""; $lname = ""; $email = ""; $email2 = ""; $pwd = ""; $pwd2 = ""; $date = ""; $error_array = array(); if(isset($_POST['register'])) { //form values $fname = clean($_POST['fname']); $_SESSION['fname'] = $fname; $lname = clean($_POST['lname']); $_SESSION['lname'] = $lname; $email = clean($_POST['email']); $_SESSION['email'] = $email; $email2 = clean($_POST['email2']); $_SESSION['email2'] = $email2; $pwd = strip_tags($_POST['pwd']); $pwd2 = strip_tags($_POST['pwd2']); $date = date('Y-m-d'); //signup date if($email == $email2) { //validate email format if(filter_var($email, FILTER_VALIDATE_EMAIL)) { $email = filter_var($email, FILTER_VALIDATE_EMAIL); //does email exist?? $email_check = mysqli_query($conn, "SELECT email FROM users WHERE email='$email'"); //number of rows returned $num_rows = mysqli_num_rows($email_check); if($num_rows > 0) { array_push($error_array, "Email already in use<br>"); } } else { array_push($error_array, "Invalid Email<br>"); } } else { array_push($error_array, "Emails don't match<br>"); } //first name length if(strlen($fname) > 50 || strlen($fname) < 2) { array_push($error_array, "Your first name must be 2-50 characters long.<br>"); } //last name length if(strlen($lname) > 50 || strlen($lname) < 2) { array_push($error_array, "Your last name must be 2-50 characters long.<br>"); } if($pwd != $pwd2) { array_push($error_array, "Your passwords don't match.<br>"); } else { if(preg_match('/[^A-Za-z0-9]/', $pwd)) { array_push($error_array, "Your password must contain English characters or numbers.<br>"); } } if(strlen($pwd) > 30 || strlen($pwd) < 2) { array_push($error_array, "Your password must be 5-30 characters long.<br>"); } if(empty($error_array)) { $pwd = md5($pwd); //encrypts password $username = strtolower($fname . "_" . $lname); $check_username = mysqli_query($conn, "SELECT username FROM users WHERE username='$username'"); //assign unique username if original is taken $snum = 0; while(mysqli_num_rows($check_username) != 0) { $snum++; $username = $username . "00" . $snum; $check_username = mysqli_query($conn, "SELECT username FROM users WHERE username='$username'"); } //assign a random profile pic $rand = rand(1,3); switch ($rand) { case '1': $profile_pic = "assets/images/profile_pics/default/01.jpeg"; break; case '2': $profile_pic = "assets/images/profile_pics/default/02.jpeg"; break; case '3': $profile_pic = "assets/images/profile_pics/default/03.jpeg"; break; } $query = mysqli_query($conn, "INSERT INTO users VALUES (NULL, '$fname', '$lname', '$username', '$email', '$pwd', '$date', '$profile_pic', '0', '0', 'no', ',')"); array_push($error_array, "<span style='color: #14C800;'>You're all set! Go ahead and login!</span><br>"); //clear session variables $_SESSION['fname'] = ""; $_SESSION['lname'] = ""; $_SESSION['email'] = ""; $_SESSION['email2'] = ""; } } //polish user imput function clean($data) { $data = str_replace(" ","", $data); $data = htmlspecialchars($data); $data = stripslashes($data); $data = strip_tags($data); $data = trim($data); return $data; } ?> I can't get the reg. form handler to recognize the $conn variable from the config.php file. if I add require '../../config/config.php'; to it I get this error:
Warning: require(../../config/config.php): failed to open stream: No such file or directory in /opt/lampp/htdocs/qcicnews/includes/form_handlers/register.php on line 3 I don't know why it can't find that file, but the way I understand PHP is that I don't need that line because it's in the register.php. When I don't use it I get a party of errors all connected to it not recognizing the $conn variable:
Notice: Undefined variable: conn in /opt/lampp/htdocs/qcicnews/includes/form_handlers/register.php on line 43
There's about 6 more that look like the ones above but from different lines where $conn is referenced, I just deleted them for brevity sake. I'm pretty new to PHP and this is the most difficult situation I've encountered so far, can someone help me find the way here?
Hi there, I am trying to create a custom registration form and connect the file to mysql using a config.php file. I created the file with a tutorial. I placed both the config.php and the registration.php in a "page-templates folder" inside the "theme folder". Using wordpress "add new page" I am able to select the registration.php file as a template. I am able to open the newly created page and type in information like username and password. I am able to press submit and I get redirected to a new page.
Problem: I would really appreciate your help. Siegfried Hi, i have tried everything i can think of to get this to work correctly. What is below here, is what i have last tried to work with..: basically the script allows the use to register an email account on a cpanel domain. Everything works perfectly but then i added a option for banned words now i cant get the script to work.. basically what happens is: the user creates an email account, if the account is not a banned word and does not exist, then the message echoes success, and the $_Post values are also entered into the database under the users name. and the email is also created with the $f fopen if success the email form also does not show.. so only one email per user.. i just cant get it to work with the banned words included.. what to note:: this is a function in a function.. $bannedemailwords='customerinformation,custinfo,customerinfo,custtext,custsupport,customersupport,admin,accounts'; $bannedmail=explode(',', $bannedemailwords); $bannedmail = array_unique($bannedmail); sort($bannedmail); foreach($bannedmail as $noemail) //the selected username if ($Config['enablemyemailapp_enable'] == '0' && $_POST['cfg_enablemyemailappaddress_enable'] !== $noemaill && $_POST['cfg_enablemyemailappaddressdomain_enable'] !== 'Select a domain'){ $cpuser = 'ausername'; $cppass = 'apassword'; $cpdomain = 'adomain'; $cpskin = 'askin'; $epass = 'somepassword'; $equota = 'somequota'; $euser = $_POST['cfg_enablemyemailappaddress_enable']; $epass = $_POST['emailspassword_enable']; $edomain = $_POST['cfg_enablemyemailappaddressdomain_enable']; if (!empty($euser) && $euser !=='nomail') while(true) { $f = fopen ("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass"a=$equota", "r"); if (!$f) { $enablemyemailapp_enable = '0'; $enablemyemailappaddress_enable = 'Replace with a Name'; $enablemyemailappaddressdomain_enable = 'Select a domain'; $msgemail = 'The email '.$euser.'@'.$edomain.' is a restricted email account.'; break; } $enablemyemailapp_enable = '1'; $enablemyemailappaddress_enable = $_POST['cfg_enablemyemailappaddress_enable']; $enablemyemailappaddressdomain_enable = $_POST['cfg_enablemyemailappaddressdomain_enable']; $msgemail ='<center><font color="#ff0033">Your Email '.$euser.'@'.$edomain.' has been created.</font></center>'; while (!feof ($f)) { $line = fgets ($f, 1024); if (ereg ("already exists", $line, $out)) { $enablemyemailapp_enable = '0'; $enablemyemailappaddress_enable = 'Replace with a Name'; $enablemyemailappaddressdomain_enable = 'Select a domain'; $msgemail ='<center><font color="#ff0033">The email account '.$euser.'@'.$edomain.' already exists.</font></center><br><center>Please try again!</center>'; break; } } echo $msgemail; $_POST['cfg_enablemyemailapp_enable']= $enablemyemailapp_enable; $_POST['cfg_enablemyemailappaddress_enable']=$enablemyemailappaddress_enable; $_POST['cfg_enablemyemailappaddressdomain_enable']=$enablemyemailappaddressdomain_enable; @fclose($f); break; } } I'm very fresh to php coding, and embedding it in html, so I'm a bit lost here. I have made a script for doing backups of mysql on the QNAP box, I want to make a page to set the variables in it, so the users don't have to change directly in the script like they do now. First the page should read in the current config, and display that in the form, and then users can change the values, and press save, quite simple I'm sure for the experienced php coder :-) I'm not sure if it's a HTML or PHP question, so here goes, if it's in the wrong forum, maybe the moderator will forgive me, and move the topic to the right one. THe page I've currently created looks like this: Code: [Select] <html><body> <h1>Mysql Backup Script</h1> <?php $config=parse_ini_file("config.txt"); ?> <form action="writeconfig.php" method="post"> <p>Days to save config: <input type="text" name="configdays" value="<?php echo $config('configdays'); ?>"/> <br> <p>Name of Backup location (share): <input type="text" name="share" value="<?php echo $config('share'); ?>"/> <br> <p>MySQL Backup User: <input type="text" name="user" value=<?php echo $config('user'); ?>"/> <p>Errorlevel (0=off, 1=error, 2=error+warn, 3=error+warn+info: <select name="error"> <option>0</option> <option>1</option> <option>2</option> <option>3</option> </select> <br> <p><input type="submit" value="Save" /> </form> </body></html> The problem is that it doesn't show the variables in the value fields, but rather the php code And the writeconfig.php looks like this: Code: [Select] <?php $configdays = $_POST['configdays']; $share = $_POST['share']; $user = $_POST['user']; $error = $_POST['error']; $int_options = array("options"=>array("min_range"=>1, "max_range"=>100)); if (!filter_var($configdays, FILTER_VALIDATE_INT, $int_options)) die("Value for number of config days is incorrect allowed value is 1-100"); $fp = fopen("config.txt", "w"); fwrite($fp, "configdays=" . $configdays . "\r\n" . "share=". $share . "\r\n" . "user=". $user . "\r\n" . "error=". $error . "\r\n"); fclose($fp); echo "Config file successfully written" ?> It's all still very raw, but the write part works ok, still needs a lot of input validation of course. As you can see, I'm still in the beginning part of this, so if I'm doing something wrong, or there's another way to do it properly, let me know! Well hello there, I want to create a script that writes a few PHP constants to a file called config.php. It does not work however, with the way I wrote it as below: Code: [Select] $configdata = "<?php //Configuration File \define("DBHOST", $dbhost); //DB Hostname \define("DBUSER", $dbuser); //DB Username \define("DBPASS", $dbpass); //DB Password \define("DBNAME", $dbname); //Your database name \define("DOMAIN", $domain); //Your domain name (No http, www or . ) \define("SCRIPTPATH", $scriptpath); //The folder you installed this script in \define("PREFIX", $prefix); ?>"; $file = fopen('../inc/config.php', 'w'); fwrite($file, $configdata); fclose($file); I am getting this error 'syntax error, unexpected T_STRING in ...', and I have no idea how to fix it. Strangely the below codes using PHP variables work flawlessly: Code: [Select] $configdata = "<?php //Configuration File \$dbhost = '{$dbhost}'; //DB Hostname \$dbuser = '{$dbuser}'; //DB User \$dbpass = '{$dbpass}'; //DB Password \$dbname = '{$dbname}'; //Your database name \$domain = '{$domain}'; //Your domain name (No http, www or . ) \$scriptpath = '{$scriptpath}'; //The folder you installed this script in \$prefix = '{$prefix}'; ?>"; //Write the config.php file... $file = fopen('../inc/config.php', 'w'); fwrite($file, $configdata); fclose($file); This confuses me, all I did was to change the string to output from a list of variables to a list of constants, and it gives weird errors that I have absolutely no idea how to fix. Can anyone please lemme know what I did wrong? Thanks. I need Delete Duplicate Email Records That Are Attached To One Account But Can Be Found In Multiple Accounts I have a table, consumer_mgmt. It collects consumer information from various forms. These forms are available through different pages that are part of a business package. A business can offer these signups to gather names and emails from consumers for various types of specials they may offer. So a consumer my be in the consumer_mgmt table 5, 10, 15 times for that particular business. But, that consumer may be in the consumer_mgmt table multiple times for a different business. So multiple times for multiple businesses. I need to remove duplicates for each business account so the consumer is only the consumer_mgmt only once for each business. There are approximately 15,000 rows currently in the consumer_mgmt table. I'm not sure where to begin on the logic. Since there are multiple business accounts that the emails are attached to, would one have to build a case for each loop? Hi all, Here i have a serious problem. I want to sought it out using PHP and MySQL only. I have a form includes fields of customer id and Account type( stored in a jump menu and includes 6 different types of accounts) <style type="text/css"> <!-- body,td,th { font-size: 18px; font-weight: bold; } --> </style> <p><img src="../images/mahapitiya 1.jpg" width="1024" height="139" /></p> <form id="form1" name="form1" method="post" action=""> <label> <input type="submit" name="button" id="button" value="Logout" /> </label> </form> <p> </p> <form action="" method="post" name="form2" id="form2" onsubmit="return Validate();"> <fieldset> <legend class="cap">Create an Account</legend> <table width="75%" border="0" cellspacing="0" cellpadding="5" align="center"> <tr> <td> </td> <td class="title02"> </td> <td> </td> <td> </td> </tr> <tr height="30"> <td width="10%"> </td> <td width="25%" class="title02" align="left">Customer ID</td> <td width="55%" class="attribute1" align="left"><input type="text" name="customer_id" class="attribute1" /></td> <td width="10%"> </td> </tr> <tr height="30"> <td> </td> <td width="25%" class="title02" align="left">Account Type</td> <td width="55%" align="left" bgcolor="#FFFFFF" class="attribute1"><select name="account_type" id="jumpMenu" > <option selected="selected"></option> <option>Savings Investment</option> <option>Shakthi</option> <option>Surathal</option> <option>Abhimani Plus</option> <option>Yasasa Certificates</option> <option>Fixed Deposits</option> </select> </td> <td width="10%"> </td> </tr> </table> <p align="center"> </p> <p align="center"> <input type="submit" onclick="return Validate();" name="submit" value="Submit" class="attribute1" /> <input type="reset" name="reset" value="Reset" class="attribute1" /> <label> <input type="submit" name="button2" id="button2" value="Help" /> </label> </p> </fieldset> </td> <td width="5%"> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td align="center"> </td> <td> </td> </tr> <tr> <td> </td> <td><font color="red" size="1" ></font></td> <td> </td> </tr> </table> </form> <p> </p> <script language = "Javascript"> function Validate() { if (document.form2.customer_id.value == '') { alert('Please enter the valid customer id!'); return false; } else if ( document.form2.account_type.selectedIndex == '' ) { alert ( "Please select an account type!." ); return false; } return true; } </script> There are 6 different types of tables exist in my database representing 6 different types of accounts.Each and every table there is a field called "account number" which is auto incremented.When user clicks on submit button i want account number to be opened based on selected account type. How this could be done? Thanks, Heshan. Actually, what i want to do is to use the email to fetch the $email,$password and $randomnumber from database after hi everyone i was wondering if anyone has any idea how i can make my php links look like this "wwwDOTmysiteDOTcom/xxx.php?s=account" right now they look like this "wwwDOTmysiteDOTcom/account.php" thanks... I have a bit of php code that sends an email. I would like to add another email recipient to this code, so that the email is sent to BOTH the post author AND the following email address... help@dealfiles.com
Yes, this is part of a Wordpress plugin. It's a small part of a large plugin that I have a LOT of time investing in setting up, so I can't just look for an alternate plugin. I really need to get this one to work.
Thanks in advance for any and all help with this. Here is the existing code: <?php if (get_post_meta( $post->ID, '_listing_contact_form', true) != '') { echo do_shortcode(get_post_meta( $post->ID, '_listing_contact_form', true) ); } else { $nameError = ''; $emailError = ''; if(isset($_POST['submitted'])) { $url = get_permalink(); $listing = get_the_title(); if(trim($_POST['contactName']) === '') { $nameError = 'Please enter your name.'; $hasError = true; } else { $name = trim($_POST['contactName']); } if(trim($_POST['email']) === '') { $emailError = 'Please enter your email address.'; $hasError = true; } else if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", trim($_POST['email']))) { $emailError = 'You entered an invalid email address.'; $hasError = true; } else { $email = trim($_POST['email']); } $phone = trim($_POST['phone']); if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['comments'])); } else { $comments = trim($_POST['comments']); } if(!isset($hasError)) { $emailTo = get_the_author_meta( 'user_email', $post->post_author ); if (!isset($emailTo) || ($emailTo == '') ){ $emailTo = get_option('admin_email'); } $subject = 'Listing Inquiry from '.$name; $body = "Name: $name \n\nEmail: $email \n\nPhone: $phone \n\nListing: $listing \n\nURL: $url \n\nComments: $comments"; $headers = 'From: '.$name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; wp_mail($emailTo, $subject, $body, $headers); $emailSent = true; } } ?> Hi all i have stumbled across an issue and really need some help i have got a function below which i am using in a wordpress plugin. here is the code. // Base function function isd_s3player() { // Plugin Url $s3url = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)); echo '<object type="application/x-shockwave-flash" data="'.$s3url.'dewplayer-playlist.swf" width="235" height="200" id="dewplayer" name="dewplayer"> <param name="wmode" value="transparent" /> <param name="wmode" value="transparent" /> <param name="movie" value="'.$s3url.'dewplayer-playlist.swf" /> <param name="flashvars" value="showtime=true&autoreplay=true&xml='.$s3url.'playlist.php&autostart=1" /> </object>'; } ok the problem i am having is i cant passed the database variable to the playlist.php which the dewplayer needs to call within the function. is their a way to somehow use or set the playlist.php in this function without having to call it seperatly??? Here is my playlist.php <?php $bucket = get_option("isd-bucket"); $folder = get_option("isd-folder"); //include the S3 class if (!class_exists('S3'))require_once('s3/S3.php'); //AWS access info if (!defined('awsAccessKey')) define('awsAccessKey', 'amazon key'); if (!defined('awsSecretKey')) define('awsSecretKey', 'amazon secret key'); //instantiate the class $s3 = new S3(awsAccessKey, awsSecretKey); // Get the contents of our bucket $bucket_contents = $s3->getBucket($bucket,$folder); header("Content-type: text/xml"); $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; $xml_output .= '<playlist version="1" xmlns="http://xspf.org/ns/0/">\n'; $xml_output .= "<trackList>\n"; foreach ($bucket_contents as $file){ $fname = $file['name']; $furl = "http://$amazon_bucket.s3.amazonaws.com/".urlencode($fname); if(preg_match("/\.mp3$/i", $furl)) { if (isset($outputted[$furl])) { continue; } $xml_output .= "\t<track>\n"; $xml_output .= "\t\t<location>" . $furl . "</location>\n"; $xml_output .= "\t\t<creator>" . $fname . "</creator>\n"; $xml_output .= "\t\t<album>" . $fname . "</album>\n"; $xml_output .= "\t\t<title>" . basename($fname) . "</title>\n"; $xml_output .= "\t\t<annotation>I love this song</annotation>\n"; $xml_output .= "\t\t<duration>32000</duration>\n"; $xml_output .= "\t\t<image>covers/smetana.jpg</image>\n"; $xml_output .= "\t\t<info></info>\n"; $xml_output .= "\t\t<link>" . $furl . "</link>\n"; $xml_output .= "\t</track>\n"; $outputted[$furl] = true; } } $xml_output .= "</trackList>"; echo $xml_output; ?> ok so as you can see right at the top i am trying to grab two option from the database but it doesnt allow you to do it this way within wordpress. So i guess what i am asking is their a way to completely skip the playlist.php file and do everything within the function??? Any help?? |