Jump to content

jasonc

Members
  • Posts

    860
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

jasonc's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. $fetch = db_query($mysqli, "SELECT * FROM `info` WHERE `section` = 'openingtimes'"); $result = $fetch->fetch_assoc(); $openingtimes = $result['content']; $openingtimes = str_replace("\r\n", " <br> ", $openingtimes); $fetch = db_query($mysqli, "SELECT * FROM `info` WHERE `section` = 'foodtimes'"); $result = $fetch->fetch_assoc(); $foodtimes = $result['content']; $foodtimes = str_replace("\r\n", " <br> ", $foodtimes); ?> <?php echo($openingtimes); ?><br><br><?php echo($foodtimes);?><br><br> Instead of accessing the DB twice only access once.
  2. Thank you I have taken the uft8 on board. It has been some years since I have coded. I am hoping to grab all the rows from the table, only 10 or so, then be able to read the results which ever 'content' column by using the 'section'
  3. CREATE TABLE `info` ( `id` int(11) NOT NULL, `section` text NOT NULL, `content` text NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; The table below is what I have setup but having issues accessing the content based on the section needed. I have tried... $result['sectionname']['content'] but nothing shows. What is the correct way to access each content using the section. without doing it one query for each one.
  4. Ok I think I understand this. But I may have more than one new field, would I be right in that I use [][] instead ?
  5. Been working on this for some time now and managed to get the new form fields added but the numbering and ids are not setup so i can submit/process the form. while($result = $fetch->fetch_assoc()) { ?> List order <input type="text" name="food[<?php echo $result['id'];?>][list_order]" id="list_order" value="<?php echo $result['list_order'];//htmlentities($itemDetails['title'], ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8");?>"><br> Food item <input type="text" name="food[<?php echo $result['id'];?>][food]" id="food" value="<?php echo $result['food'];//htmlentities($itemDetails['title'], ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8");?>"><br> Price (each) <input type="text" name="food[<?php echo $result['id'];?>][price]" id="price" value="<?php echo $result['price'];//htmlentities($itemDetails['title'], ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8");?>"> <br><br><?php } ?><div id="addFields"> </div> <a href="javascript:void();" onClick="addField('food');">Add Field</a><br><br> function addField(name) { var EL = document.getElementById('addFields'); var fieldNum = (EL.children.length)+1; var HTML = ''; for(i=0; i<EL.children.length; i++) { var total = (EL.children[i].children[0].value) + 1; HTML += '<div>List order <input type="text" name="food[][list_order]" id="list_order" value="'+total+'"><br>Food item <input type="text" name="food[][food]" id="food" value=""><br>Price (each) <input type="text" name="food[][price]" id="price" value=""><br><br></div>'; } HTML += '<div>List order <input type="text" name="food[][list_order]" id="list_order" value="'+fieldNum+'"><br>Food item <input type="text" name="food[][food]" id="food" value=""><br>Price (each) <input type="text" name="food[][price]" id="price" value=""><br><br></div>'; EL.innerHTML = HTML; } Say there are already 5 items showing numbered 1 to 5 (when submitted I will add/change the items as edited, if any. And insert the new items if any. If new items then these will get added to the DB without an ID as it will auto assign this. The list order is to allow the users to add new items and state in which order they show on the end user page. My issue is how to add new items to the form and get these processed from the backend php even though there is no ID. Just a thought, should I have two POSTS, one for existing items and a 'new' POST information sent that I can insert in the DB ? Not sure how best to do this one. Does anyone have any ideas on a way that would work ?
  6. I have not used radio buttons but a long time. I wish to have an approve page show the images with keep or delete radio buttons underneath. There would be a few images showing at any one time waiting to be checked. I do not need a default selection for any as they admins can leave them and check again another time. <div class="floatLeft"> <img class="maxwidth" src="uploads/S<?php echo($result['img_name']); ?>"> </div> <div class="floatLeft">&nbsp;&nbsp;<strong>Username:</strong><?php echo(htmlentities($result['user_name'])); ?></div><br> <div class="floatLeft">&nbsp;&nbsp;<strong>Description:</strong> <?php echo($result['description']); ?></div><br> <div class="floatLeft">&nbsp;&nbsp;<?php echo($result['created']); ?></div><br> <div class="clearFloat"></div> <div class="floatLeft"><input type="radio" name="list[]" value="<?php echo($result['id']); ?>">Approve</div> <div class="floatLeft"><input type="radio" name="del[]" value="<?php echo($result['id']); ?>">Delete</div> <div class="clearFloat"></div> The radio buttons is where I am having issues. They work but not as needed as I am able to select both delete and approve for only one. Looking to have it grouped by photo. I am not sure how I should group each photo seperately.
  7. I am just after a javascript regex that checks that the format of the email looks like and email not if it exists.
  8. I would like to cater for all devices/pc. I just tried the if statement you gave and it allowed ssss@gg@.gfh Just checking that the email is looking ok is fine, i.e. no spaces, no strange characters and that. They could still type in thisemaildoesnotexists@gmailfake.com but then we'd see that when we go to reply !
  9. I did use the HTML5 but it is not supported on most andriod devices
  10. Thank you for this, but how do I add this in to my existing code like above ? I already have the errormessage added to the top of the field if it is needed. I already have it checked server side but still could fail when we reply to their message anyway.
  11. I just can not seem to find a javascript code that checks if the email format is correct. I know that someone could enter an bogus email address but thats ok. I am just after checking if the format of the email entered looks correct before the form is submitted. Please can I have some suggestions of what others have used. It could be that I am doing this wrong... if (/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(email.value.lrtrim())) { errorMessage = 'Email contains invalid character/s';
  12. I thought that at first but there is a large unsubscribe link (three times the size of other text) which is why I placed it on a line of its own at the bottom of the email. The length of the email is never more than one standard screen length. I manually sent the mailshot from my pc to a few that bounced back as it was thought to be spam and the person got it. We even contacted a few of them by phone to see if they were filtering any email but no one is. But still it does not explain why say 20 fail one time and another ten fail yet another time, rarely two return from the same email address. Just a thought... So if the server was to auto send out say 100 and a number of them returned undelivered due to it might be spam, should I stop there and then from sending out any more from that batch to be sent and wait a short time before resuming to prevent some of the rest from being seen as possible spam?
  13. Setup of the email takes no more than a few minutes. My host has already set up SPF and DKIM. As for bounce rate one bounce and I have to manually check the returned email to decide if the customers email address (if exists still) will get any more emails. Out of the 500 ish subscribers we might get 2 or 3 that come back as no longer found as the employee does not work for that company anymore. The ones that I am worried about are the 20 or 30+ that come back and not delivered due to spam score rating. They are completely random and not the same customer email. Otherwise it would be that these customers are marking it as such.
  14. This has been an ongoing issue from the start. When I try to login I enter the username and password and click login, then get taken back to the login page to reenter the same details and the second time I click login I get logged in. Now if I then log out and close window and wait a few seconds, restart again and try to log in, I get in first time. I believe this could be a session issue but I thought unsetting the unset($_SESSION['admin']); would cause the session to be lost and have to start again. I just can not get my head around what is causing it. Can anyone tell me what I might be doing wrong ? I have a redirect to originating page, so if I was to view a previous page within the admin area I have to log in and then once loggeed in it will redirect to the page I was on before. Here are my scripts. adminCreateCampaign.php <?php session_set_cookie_params(0, '/', '.****.com'); session_start(); error_reporting(-1); define('site_title', 'Admin '); define('pageTitle', 'Admin '); $_SESSION['loginRedirect'] = "adminCreateCampaign.php"; include("functions-for-email.php"); $checkAdminStatus = checkAdminStatus($mysqli); if(!isset($_SESSION['admin']) || $checkAdminStatus == "NOACCESS") { $_SESSION['error'] = 'You must be logged in to view that page. (el.S1)'; //$_SESSION['loginRedirect'] = "showStats.php"; //echo("You must be logged in to view that page. (el.S1)<br>"); exit; @mysqli_close($mysqli); header('Location: ' . adminFullWebAddress . '/index.php'); exit; } else { if($_SESSION['admin']['account_type'] != 'admin') { $_SESSION['error'] = 'You do not have the priviledges to view that page. (el.S2)'; @mysqli_close($mysqli); header('Location: ' . adminFullWebAddress . '/index.php'); exit; } } ?> <!DOCTYPE> <html> <head> <link href="adminstyle.css" rel="stylesheet" type="text/css" /> <title><?php echo(site_title); ?></title> </head> <body> <div id="container"> <div class="containerInner"> <div id="leftInner100"> <?php // start of leftInner ?> <?php menu(); ?> <h1 class="middleTitle">Admin </h1> <?php if(isset($thisError)) { echo '<div class="errorDiv">',$thisError,'</div>'; unset($thisError); } if(isset($thisSuccess)) { echo '<div class="successDiv">',$thisSuccess,'</div>'; unset($thisSuccess); } ?> <br><br> </div><?php // end of leftInner ?> </div><?php // end of containerInner ?> <div class="clearfix"></div> </div><?php // container ?> </body> </html> <?php @mysqli_close($mysqli); ?> index.php <?php session_set_cookie_params(0, '/', '.****.com'); session_start(); error_reporting(-1); include("functions.php"); $checkAdminStatus = checkAdminStatus($mysqli); //$_SESSION['loginRedirect'] = adminFullWebAddress . "/index.php"; $fromlink4 = isset($_SERVER['REMOTE_ADDR']) ? (gethostbyaddr($_SERVER['REMOTE_ADDR'])) : "empty"; $ipAddress = $_SERVER['REMOTE_ADDR']; if(isset($_POST['email'])) { $email = $_POST['email']; $email = strip_tags($email); } else { $email = ""; } if(isset($_POST['pass'])) { $password = $_POST['pass']; $pass = $_POST['pass']; } else { $pass = ""; } if(isset($_POST['login']) && trim($_POST['login']) == 'Login') { $checkEmail = db_query($mysqli, "SELECT `adminid` FROM `admins` WHERE `email` = '" . $mysqli->real_escape_string($email) . "' LIMIT 1"); $checkBanned = db_query($mysqli, "SELECT `adminid` FROM `admins` WHERE `email` = '" . $mysqli->real_escape_string($email) . "' AND `suspended` = 'Yes' LIMIT 1"); $failedLoginCounter = 0; if(!$email) { $thisError = 'Please enter your e-mail address.'; } else if(! $checkEmail->num_rows) { $thisError = 'Either the email address, password or both were not entered correctly.'; } else if(!$password) { $thisError = 'Please enter your password.'; } else if($checkBanned->num_rows) { $thisError = 'Your account has been suspended by Admin.'; } else { $password = md5($password); $checkAccount = db_query($mysqli, "SELECT * FROM `admins` WHERE `email` = '" . $mysqli->real_escape_string($email) . "' AND `password` = '" . $mysqli->real_escape_string($password) . "' LIMIT 1"); if($checkAccount->num_rows) { $saveChanges = db_query($mysqli, "UPDATE `admins` SET `lastlogindatetime` = '" . $mysqli->real_escape_string(datetimenow) . "', `lastAccessSinceLogin` = '" . $mysqli->real_escape_string(datetimenow) . "', `lastloginip` = '" . $mysqli->real_escape_string($ipAddress) . "', `failedLoginCounter` = 0 WHERE `email` = '" . $mysqli->real_escape_string($email) . "' LIMIT 1"); // set lastlogindatetime $_SESSION['admin'] = $checkAccount->fetch_assoc(); $loginRedirect = isset($_SESSION['loginRedirect']) ? $_SESSION['loginRedirect'] : ""; $_SESSION['success'] = 'You are now logged in. (ok.L2) ' . $loginRedirect; header('Location: ' . adminFullWebAddress . '/' . $loginRedirect); exit; } else { $thisError = 'Your e-mail address and/or password is incorrect.<br>If you still face issues, you can <a href="startresetpw.php">reset your password</a>'; $saveChanges = db_query($mysqli, "UPDATE `admins` SET `failedLoginCounter` = `failedLoginCounter` + 1, `lastloginfailedip` = '" . $mysqli->real_escape_string($ipAddress) . "', `lastlogindatetimeFailed` = '" . $mysqli->real_escape_string(datetimenow) . "' WHERE `email` = '" . $mysqli->real_escape_string($email) . "' LIMIT 1"); // set lastlogindatetimeFailed } } } if(!isset($_SESSION['admin'])) { define('site_title', 'Login'); define('pageTitle', 'Login'); } else { define('site_title', 'Home'); define('pageTitle', 'Home'); } ?> <!DOCTYPE> <html> <head> <link href="adminstyle.css" rel="stylesheet" type="text/css" /> <title><?php echo(site_title); ?></title> </head> <body> <div id="container"> <div class="containerInner"> <div id="leftInner100"> <?php // start of leftInner ?> <div id="mainphoto"><?php //specialMessage($mysqli); mainPageImage(""); ?></div> <div class="clear"></div><?php if(isset($_SESSION['admin'])) { menu(); } if(isset($thisError)) { echo '<div class="errorDiv">',$thisError,'</div>'; } if(isset($thisSuccess)) { echo '<div class="successDiv">',$thisSuccess,'</div>'; } unset($thisError); unset($thisSuccess); if(!isset($_SESSION['admin'])) { ?> <div style="width: 100%; margin: 0em auto; text-align: center;"> <form method="POST" action="index.php" style="width: 15em; text-align: center;"> <div class="field"> E-mail Address </div> <div class="value"> <input type="text" name="email" value="<?php if(isset($_POST['email'])) { echo $email; } ?>" style="width: 12.5em;" title="email"> </div> <div class="field"> Password<br><span style="font-size: 0.8em;"><?php if (isset($_POST['pass'])) { echo('<strong style="color: red;">'); } ?>(Please note: your password may be CaSe SeNSitIvE)<?php if (isset($_POST['pass'])) { echo('</strong>'); } ?></span> </div> <div class="value"> <input type="password" name="pass" value="" style="width: 12.5em;" title="pass"> </div> <div><br><input type="submit" name="login" value="Login"> <input type="reset" value="Clear"><br></div> </form><br> <div class="clearFloat"></div> </div> <?php } else { ?>logged in<?php } ?> <br><br> </div><?php // end of leftInner ?> </div><?php // end of containerInner ?> <div class="clearfix"></div> </div><?php // container ?> </body> </html> <?php @mysqli_close($mysqli); ?> functions.php <?php define('showOutput', 0); include("/home/****/db_login_functions.php"); define('db_table_name', 'clientList'); define('mailHost', 'mail.****.com'); define('mailUsername', 'noreply@****.com'); define('mailPW', '****'); define('bounce', 'bounce@****.com'); define('fullDomain', 'https://www.admin.****.com'); define('adminFullWebAddress', 'https://www.admin.****.com'); define('adminEmail', 'admin@****.com'); define('fromEmail', 'noreply@****.com'); define('fromName', 'DO NOT REPLY'); define('REMOTEADDR', isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''); define('PHPSELF', $_SERVER['PHP_SELF']); define('HTTPREFERER', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "not set"); define('unsub', 'https://www.****.com/unsub.php'); define('securityhash', 'abc'); // NEVER change this securityhash. date_default_timezone_set('Europe/London'); define('datetimenow', date("Y-m-d H:i:s")); /* check if user is allowed to access a certain page or not. */ function checkAdminStatus($mysqli) { $yesNo = ""; if(isset($_GET['action']) && $_GET['action'] == 'logout') { unset($_SESSION['admin']); $_SESSION['success'] = 'You have successfully logged out. (lo.1)'; header('Location: index.php'); exit; } if(isset($_SESSION['admin']) ) { // need to add in code to check if logged in for more than 1 hour, if so log out on next refresh of page. if ($_SESSION['admin']['lastAccessSinceLogin'] < date( 'Y-m-d H:i:s', strtotime("-5 minutes") )) { unset($_SESSION['admin']); $_SESSION['error'] = 'You were logged out due to no activity, please login again to view that page. (lo.2)'; header('Location: index.php'); exit; } $checkBanned = db_query($mysqli, "SELECT `adminid` FROM `admins` WHERE `email` = '" . $mysqli->real_escape_string($_SESSION['admin']['email']) . "' AND `suspended` = 'Yes' LIMIT 1"); if($checkBanned->num_rows) { $yesNo = "NOACCESS"; //$_SESSION['error'] = 'You must be logged in to view that page.'; } else { $yesNo = "ACCESS"; // if logged in, update `users`.`lastAccessSinceLogin` with current datetime. $updateLastAccessSinceLogin = db_query($mysqli, "UPDATE `admins` SET `lastAccessSinceLogin` = '" . $mysqli->real_escape_string(datetimenow) . "', `lastloginip` = '" . $mysqli->real_escape_string(REMOTEADDR) . "', `failedLoginCounter` = 0 WHERE `email` = '" . $mysqli->real_escape_string($_SESSION['admin']['email']) . "' LIMIT 1"); $_SESSION['admin']['lastAccessSinceLogin'] = datetimenow; } } return $yesNo; } function menu() { echo('<a href="index.php?action=logout">Log Out</a>&nbsp;&nbsp;&nbsp;&nbsp;'); echo(' <a href="adminCreateCampaign.php">Create Campaign</a><br><br><br>'); } ?> .htaccess (within the admin folder) Header set Access-Control-Allow-Origin "*" RewriteEngine On RewriteCond %{HTTPS} off # First rewrite to HTTPS: # Don't put www. here. If it is already there it will be included, if not # the subsequent rule will catch it. RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Now, rewrite any request to the wrong domain to use www. # [NC] is a case-insensitive match RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] ### DON'T DELETE!! Below entry is MUST for your PHP sites like wordpress,joomla and etc to work properly. suPHP_ConfigPath /home/****/php.ini .htaccess (within the root folder) Header set Access-Control-Allow-Origin "*" RewriteEngine On RewriteCond %{HTTPS} off # First rewrite to HTTPS: # Don't put www. here. If it is already there it will be included, if not # the subsequent rule will catch it. RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Now, rewrite any request to the wrong domain to use www. # [NC] is a case-insensitive match RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] ### DON'T DELETE!! Below entry is MUST for your PHP sites like wordpress,joomla and etc to work properly. suPHP_ConfigPath /home/****/php.ini the php.ini file allow_url_fopen = on allow_irl_include = on date.timezone = Europe/London safe_mode = off upload_max_filesize = 20M post_max_size = 20M upload_tmp_dir = "/home/****/tmp" session.save_path = "/home/****/sessions" session.use_only_cookies = on error_reporting = E_ALL log_errors = On display_errors = Off track_errors = On error_log = "/home/****/errors.log" sendmail_from = "server@****.com"
×
×
  • 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.