Jump to content

stevengreen22

Members
  • Posts

    119
  • Joined

  • Last visited

Everything posted by stevengreen22

  1. I'm currently working with someone on a site and we've gotten to the point where we're looking for feedback or suggestions etc. The site is currently located at www.steve-t-green.com/perspect/index.php If you could have a peek and maybe take a moment to fill this in : http://kwiksurveys.com/app/rendersurvey.asp?sid=5dt1vdmfhapx00y222151&refer= I'd be hugely grateful. Failing that any and ALL criticisms are welcome. A couple of notes, any links that do not work is intentional, any pages that are not there is also intentional. Many many thanks.
  2. Hi all, This problem is killing me. I hope / pray someone can help. Essentially I need to pass a JS variable to a PHP variable without refresh/form submission or redirecting. I'm new to Ajax so please be patient The owner of this site generally lives in 3 countries lucky ******. When he logs in he wants the contact page updated with his current number. I have a form with hidden fields that return the address location using an ajax call to ipinfo.io - this works fine. <script> $(function() { var admin = <?php echo json_encode($admin->isAdmin($user['username'])); ?>; var phone=""; if(admin == true){ $.ajax({ url:"http://ipinfo.io", dataType:'jsonp' }) .success(function(response){ $("#address").val(response.country); $("input[id=address]").val(response.country); var testLoc = $('#address').val(); if(testLoc == "GB"){ phone = "<?php echo $gb?>"; $("#phone").append(phone); }else if(testLoc == "GABON"){ phone = "<?php echo $gabon?>"; $("#phone").append(phone); }else if(testLoc == "THAILAND"){ phone = "<?php echo $thai?>"; $("#phone").append(phone); } }); var time = new Date(); $("#localTime").append(time); }else{ //alert("Not Admin"); $("#phone").append(phone); } }); </script> The above essentuially checks to see that he is THE admin, if it is it then sets the hidden field value to be the country, that is then placed in the testLoc variable and depending on what it is, it spits out the number. This all works well unless of course you visit the site and you're not the admin. All you see is an empty string. I need to get that phone variable or location variable, either of them really from the js into a php variable. That way when a normal joey visits the page I can just echo out that variable instead. phone or location var in js script to php variable?
  3. Hi, I'm turning a 2 level nav into a 3 level and running into a few difficulties. The 3rd level displays where and as predicted but when the 'grandparent' is hovered over, not the parent of the items I want displayed. I've been fooling around with the css for a while and I cannot get it to respond how I'd like. Any help is appreciated. There is a fiddle as my explanation might be somewhat lacking. http://jsfiddle.net/6TGaf/ Code from fiddle: #nav{ background: #bada55; width: 99%; margin-top:-5px; } #nav ul{ list-style: none; margin: 0; padding: 0; height: 40px; } #nav ul li{ /*child elements positioned absolutley will be relative to this*/ position: relative; border-top: 1px solid #e9e9e9; float: left; } #nav a{ color: ghostwhite; padding: 12px 0px; /*fill hori space*/ display: block; text-decoration: none; /*apply transition to background property, taking 1s to change it */ transition:padding 1s, background 1s; -moz-transition:padding 1s, background 1s; -webkit-transition:padding 1s, background 1s; -o-transition:padding 1s, background 1s; font-family:tahoma; font-size:13px; text-transform:uppercase; padding-left:20px; } /*hover pseduo class*/ #nav a:hover{ /* RGBA background for transparancy: last number(0.05) is the transparency */ padding-left:35px; background: RGBA(255,255,255,0.05); color:#fff; } #nav ul li:hover ul{ /*diplay when hovered*/ display: block; } #nav ul ul{ position: absolute; left: 0px; top: 40px; border-top: 1px solid #e9e9e9; display: none; /*width: 304px;*/ z-index: 1; } #nav ul ul li{ width: 150px; background: #f1f1f1; border: 1px solid #e9e9e9; border-top: 0; /*float:left;*/ } #nav ul ul li a{ color:#000000; font-size:12px; text-transform:none; } #nav ul ul li a:hover { color:#929292; } /*3rd level...*/ #nav ul ul ul{ position: absolute; left: 150px; top: 0px; border-top: 1px solid #e9e9e9; display: none; /*width: 304px;*/ z-index: 1; } #nav ul ul ul li{ width: 150px; background: #f1f1f1; border: 1px solid #e9e9e9; border-top: 0; } #nav ul ul ul li a{ color:#000000; font-size:12px; text-transform:none; } #nav ul ul ul li a:hover { color:#929292; } #nav ul ul li:hover ul{ /*diplay when hovered*/ display: block; } <nav id = "nav"> <ul> <li> <a href="#">1.1</a> <ul> <li> <a href="#">1.1.1</a> <ul> <li><a href="#">1.1.1.a</a></li> <li><a href="#">1.1.1.b</a></li> </ul> </li> <li><a href="#">1.1.2</a></li> <li><a href="#">1.1.3</a></li> </ul> </li> </ul> </nav>
  4. OK, I think I was getting confused. I was trying to cirumnavigate the problems for when I try and access the includes from a different folder in the root. 2 levels down for example and I've just realised that this doesn't actually solve that. Would $file = dirname(__FILE__) be on the right track to solve?
  5. oh ok, changed to .class.php. In my dbconnect.class.php I only have : $config = array( host etc details ); $db = new PDO('mysql:host=' .$config['host'] . ';dbname=' .$config['dbname'], $config['username'], $config['password']); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); Is there any problems there? when you mentioned class name and file name I got a touch confused. This doesn't have typical class structure
  6. Hi, It was dbConnect.php. I then tried dbconnect.php and dbconnect.class.php. It's now dbconnect.php again
  7. Hi, yup, checked all of those and they're all fine. I've tried various tests and so far have come up with this result... If I include the dbconnect file using require before I call the spl_autoload it works. I tried putting the dbconnect file into the same folder as the classes to test - it failed there too.
  8. I have : session_start(); spl_autoload_register(null, false); spl_autoload_extensions(".class.php"); function classLoader($class){ $filename = strtolower($class) .'.class.php'; $file = 'core/classes/' .$filename; if(!file_exists($file)){ return false; } require $file; } function connectLoader($connect){ $filename = strtolower($connect) .'.class.php'; $file = 'core/connect/' .$filename; if(!file_exists($file)){ return false; } require $file; } spl_autoload_register('connectLoader'); spl_autoload_register('classLoader'); In an init.php that is called at the top of each page. I keep receiving errors with regards to non member objects when trying to access the site. Fatal error: Call to a member function prepare() on a non-object in /home/a6696695/public_html/core/classes/users.class.php on line 185 on that line is a function that retrieves user data from the database: //function to return the user data public function userData($id){ $query = $this->db->prepare("SELECT * FROM users WHERE id =?"); $query->bindValue(1, $id); try{ $query->execute(); //returns all user data in the form of an array - access in other pages, index etc. return $query->fetch(); }catch(PDOException $e){ die($e->getMessage); } }//end userData function This function is called in the init after the spl calls. //instantiating the classes $users = new Users($db); $admin = new Admin($db); $general = new General(); $helper = new Helper(); //check if user is logged in, get id from session and data if($general->loggedIn() === true){ $userId = $_SESSION['id']; $user = $users->userData($userId); } Help please
  9. Issues with formatting in here -.- This works fine...if it's not the first time a user visits the site. This is the mess I get after inspecting with firebug: value="<br><table border='1' cellpadding='2' bgcolor='#FFFFDF' bordercolor='#E8B900' align='center'><tr><td><font face='Arial' size='1' color='#000000'><b>PHP Error Message</b></font></td></tr></table><br /> <b>Notice</b>: Undefined index: cookieUserEmail in <b>/home/a6696695/public_html/contact.php</b> on line <b>231</b><br /> <br><table border='1' cellpadding='2' bgcolor='#FFFFDF' bordercolor='#E8B900' align='center'><tr><td><div align='center'><a href='http://www.000webhost.com/'><font face='Arial' size='1' color='#000000'>Free Web Hosting</font></a></div></td></tr></table>" name="email" style="width: 200px;"> It's a feature that I'd like to keep but I can't find a solution. I tried declaring the cookie variables right at the start to be empty strings but that failed. Am I missing something obvious(again)?
  10. Hi all, I've a contact form with a save details option. <div class="ourContactFormElement"> <label for="email"><span class="requiredField">*</span>Your Email:</label> <input type="text" name="email" class="required email" value="<?php echo $_COOKIE["cookieUserEmail"]; ?>"<?php if(isset($_POST['email'])){ echo 'value="', htmlspecialchars($_POST['email'], ENT_QUOTES, 'UTF-8'), '"';} ?> /> </div>
  11. That makes so much more sense now. I feel ashamed. You are now on my christmas card list
  12. Hi all, I'm trying to avoid using external libraries as much as possible, mainly because I'd liek to try and understand things myself instead of relying on their code. I've got an email working fine that displays in HTML courtesy of some online guides / tutorials and a fair bit of frowning. I now need to embed some GIF's or images into it but I'm having zero success. The images are stored on the server and have been used in various other places so I'm certain the path is correct as I thought this may be the issue. If I take an example from CSS-Tricks and use a http:..... path image. It works fine but I don't want to do this, I'd like to tell it that the file is "images/bla.gif" and so on. I've found some help online but after trying examples I'm still in the same position that I was before. Could someone take a look at the code and help please? $subject = "Contact Form"; $headers = "From: " .$email. "\r\n"; $headers .= "Reply-To: " .$email. "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; //body of message $message1 = '<html><body>'; $message1 .= '<table rules="all" style="border-color: #666;" cellpadding="10">'; $message1 .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" .$name. "</td></tr>"; $message1 .= "<tr><td><strong>Email:</strong> </td><td>" .$email. "</td></tr>"; $message1 .= "<tr><td><strong>Company Name:</strong> </td><td>" .$companyName. "</td></tr>"; $message1 .= "<tr><td><strong>Contact Number:</strong> </td><td>" .$contactNumber. "</td></tr>"; $message1 .= "<tr><td><strong>Message:</strong> </td><td>" .$message. "</td></tr>"; $message1 .= "</table>"; $message1 .= '<IMG SRC="images/loading.gif" alt="GAAAAAh"/>'; -- THIS DIESN"T WORK - THE ONE BELOW DOES -.- $message1 .= '<img src="http://css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />'; $message1 .= "</body></html>"; if (mail($myEmail, $subject, $message1, $headers)) {
  13. Wow, thanks guys, I wasn't expecting so much and the above class is pretty awesome I went back to basics so to speak to try and understand the problem a bit better. There are many different types of units that will need to be converted so I was working on a select boxes that auto populated depending on the previous choice. This then menat leaning or attempting to learn jquery and js in part to try and understand those functions needed. I'll then piece this all together. Hopefully:)
  14. Hey all, I'm trying to write a fairly intensive unit converter. I only want to use PHP to achieve it. There's tons of online material for a JS version but that won't do I'd also like to use classes as well to help organise things (and it's what I know). The problem is...I don't really know where to start. I'm intending on having a form of course where a user can select a unit type and how many of that unit. The output will then display all the other units for that measurement. So length for example : 1 cm would output 10 mm; metres, yards etc etc For my other forms I've used POST to get the details but I found an example online that uses method="$_SERVER['PHP_SELF']" instead could someone be kind enough to guide me in the right direction please? Many thanks
  15. I'm sure there's a better way but in the meantime I've used: <?php //is there a better way? Sets the cookies to be null values so html markup is not //presented the first time a page is loaded setcookie("cookieUserEmail",' '); setcookie("cookieUserName",' '); setcookie("cookieUserCompany",' '); setcookie("cookieUserContact",' ');?> <?php at the very top of the page to solve the issue.
  16. Hi all, Come across a strange issue and I'm not sure how to solve it. I've a form that asks if a user wants to save the details until next time. The problem is that if there are no cookies set it displays html in the table fields that the user has to delete. This was working fine but I've changed so many things I can't think of what it could be. I've this in the php //save the details as a cookiiiiie if selsected $saveDetails = $_POST['saveDetails']; if($saveDetails == 'on'){ setcookie("cookieUserName", $_POST['name'], time()+60*60*24*365); setcookie("cookieUserEmail", $_POST['email'], time()+60*60*24*365); setcookie("cookieUserCompany", $_POST['companyName'], time()+60*60*24*365); setcookie("cookieUserContact", $_POST['contactNumber'], time()+60*60*24*365); } and then in the form itself: <form action="" method="post" id="ourContactFormID_JS"> <input type="hidden" name="token" value="<?php echo $newToken; ?>"> <div class="ourContactFormElement"> <label for="name"><span class="requiredField">*</span>Your Name:</label> <input type="text" id="name" name="name" class="required" value="<?php echo $_COOKIE["cookieUserName"]; ?>" <?php if(isset($_POST['name'])){ echo 'value="', htmlspecialchars($_POST['name'], ENT_QUOTES, 'UTF-8'), '"';} ?> /> </div> <div class="ourContactFormElement"> <label> </label> <input type="submit" value="Send Request!" /> </div> <div class="ourContactFormElement"> <label> </label> <input type="checkbox" name="saveDetails" /> <label for="saveDetails"> Save Contact Details?</label> </div> </form> When using firebug on the element I can se all the html. this is the first line: <input class="required email jqtranformdone jqTransformInput error" type="text" value="<br><table border='1' You can see that it starts from where the 'value=' is. I've removed that line from my form and it displays fine so that is definitely the issue but it's a feature that I'd like to keep, any ideas?
  17. I edited the code to cut a lot out to save the space needed for pasting here. On the first attempt i used comments and made it all nice, the 2nd attempt had less comments and the 3rd attempt is what you see here. The url is wrong, should have the .php before the ?sent of course. $message1 etc is the body and headers of the email with the remainder removed. $errors is an array thats declared in a file that's always included. As each error occurs it gets added to the array and then output later. That again works well in another form I have. The email begin sent was commented out in the above, it does work:) I did figure out what the issue was, I made use of a jquery library to tidy and validate the form, the order in which I called php / js etc was all wrong so it was never getting there. I then found a mistake in the js file where i was targeting an id to append instead of a class. With that now working I have no need for the redirect so the code has been cleaned a lot! Thank you for taking the time to read and comment. Don't suppose you know why the code tags weren't working for me? Thanks again
  18. if(verifyContactFormToken('ourContactForm')){ if(isset($_POST['name'])){ //may have to change to see if a field was set instead $myEmail = 'stevegreen22@me.com'; //Email address where queries get sent. //errors already defined in init $name = strip_tags(trim($_POST['name'])); $email = strip_tags(trim($_POST['email'])); $contactNumber = strip_tags(trim($_POST['contactNumber'])); $companyName = strip_tags(trim($_POST['companyName'])); $message = strip_tags(trim($_POST['message'])); //url check if relevant //make sure no urls are in any of the fields $errors[]= 'Please do not enter url\'s in any of the fields.'; } //check email address! if(!filter_var($email, FILTER_VALIDATE_EMAIL)){ $errors[] = 'Please enter a valid email address.'; } //body of message $message1 =$subject = $headers = - to save space if(empty($errors) === true){ //mail($myEmail, $subject, $message1, $headers); header('Location: contact?sent.php'); exit(); //echo 'Your message was sent'; } } }else{ if(!isset($_SESSION[$ourContactForm.'_token'])){ }else{ echo "Hack attempt. Fail."; } } ?> <!doctype html> <html xmlns="http://www.w3.org/1999/html"> <head> </head> <?php //create a new token for checking form authenticity $newToken = createContactFormTokens('ourContactForm'); ?> <body> <div class="container"> <?php include 'include/header.php'; ?> <?php include 'include/sidebar.php'; ?> <div class="content"> <div id="ourContactForm"> <h2>Please use the form below to contact us.</h2> <?php echo 'yasdfasdfsdaf'; //no output if(!empty($errors)){ echo '<div class="errors">'; echo '<h3>Errors:</h3>'; echo '<p>' . implode('</p><p>', $errors) . '</p>'; echo "</div>"; }else if(isset($_GET['sent'])){?> <div class='success'>Thank you for contacting us.</div> <?php } ?> <!-- Using juery plugins to validate instead of html5 - 'required' for example.--> <form action="" method="post" id="ourContactFormID_JS"> <input type="hidden" name="token" value="<?php echo $newToken; ?>"> <div class="ourContactFormElement"> <label for="name"><span class="requiredField">*</span>Your Name:</label> <input type="text" id="name" name="name" class="required" minlength="2" <?php if(isset($_POST['name'])){ echo 'value="', htmlspecialchars($_POST['name'], ENT_QUOTES, 'UTF-8'), '"';} ?> /> </div> <div class="ourContactFormElement"> <label for="email"><span class="requiredField">*</span>Your Email:</label> <input type="text" name="email" class="required email" <?php if(isset($_POST['email'])){ echo 'value="', htmlspecialchars($_POST['email'], ENT_QUOTES, 'UTF-8'), '"';} ?> /> </div> <div class="ourContactFormElement" id="message"> <label for="message"><span class="requiredField">*</span>Message:</label> <textarea cols="30" rows="8" name="message" class="required" minlength="2"></textarea> </div> <div class="ourContactFormElement"> <label> </label> <input type="submit" value="Send Request!" /> </div> </form> </div> <div class="clearfloat"></div> <!-- end .content --></div> <?php include 'include/footer.php'; ?> <!-- end .container --></div> </body>
  19. my code doesn't appear to be showing..? Apologies, I had to paste it below.
  20. Hi all, I'm relatively new to PHP and have spent the past 5 hours trying to figure out what the issue is with this code. What I'm trying to achieve is sending a message to the user once the email has been sent or not as the case may be. I've tried everything I can think of but still can't solve it. I've checked for whitespace, there are no obvious errors. I've also tried putting an echo after the mail function but that doesn't get output either yet the mail gets sent and is received. If there's an alternative way of displaying a message on the same page then that'd be great to know too. This is the only way I know at the moment. If there is success send the user to the same page but append the url and then use a get to see if the url was appended and if so present a new message. That works on a few other pages, just not this one. Any help is appreciated. I've a require at the very top that has includes in, there's no whitespace and error_reporting(E_ALL); ini_set('display_errors', 'On'); doesn't display any errors
  21. Hi guys, Thanks for taking the time to read. I'm working on a project and was just"polishing" things. I found an awesome background image that I want stretched. I've got this to work but then it wouldn't validate. I then contained it within another div but it seems to be sitting on top of all of the others even when I've set the z-index to negative. Can you please help? I have... html { height:100%; margin:0; padding:0; } #bg { position:fixed; top:0; left:0; width:100%; height:100%; z-index: -999; -moz-background-size:100% 100%; /* Firefox 3.6 */ background-size:100% 100%; background-repeat:no-repeat; background-image:url(btest2.jpg); } body { width:100%; height:100%; margin:0; padding: 0; font-family: arial, helvetica, sans-serif; height:100%; position:relative; for the css and </head> <body> <div id ="bg"> <div id="wrapper"> <div id="header"> is the relevant part of the html. Many thanks!
  22. Hi guys, I'm hoping someone may be able to help and that the lack of PHP in the topic wont be a deterrant. I've a task that involves creating a website that imitates an online shop. Theres a database involved with relevant info for obtaining the details. So far, I've got the site up and running using both html pages and servlets. I can run queries to the db using the servlet and postgres and can also display the info on another screen. What I'd like to do is firstly find out the correct method for inserting the information gathered such as card details etc into the db and also how I can use this to reflect stock levels? I'm thinking that as soon as something is bought I must have to 'delete' that item from the stock while inserting the item and card details etc into 2 new tables (payments and cust info) Could anyone help please? Also...I'm searching for a way to validate the information given. I'd like to restrict the text field for contact numbers to nothing but numbers. And also for the card lenght, must be 16 digits etc. For card length I cna see the logic fairly clearly in that : if (cardLength > 16){print error etc}else{return} (I think this is structured incorrectly but I hope the logic is partially right. Many thanks for your time and help!
  23. That makes sense with something one of those video's mentioned. Design for the newest browsers and work backwards so to speak. I'm really liking some of the css3 stuff - There's always walking before running though
  24. yup - quite impressed I got it right But this is only geared towards IE. Does that mean that the -webkit / -moz are not conditional although they do the same thing? but...they're quite generic in taht they don't specify versions and the browsers are generally better equipped than IE. But (to drag this on) would you really write statements for IE 5?!? ...it's slightly shocking to think that IE would be allowed to be weak in areas that it's competition are not?!?
×
×
  • 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.