Jump to content


  • Posts

  • Joined

  • Last visited

justin7410's Achievements


Member (2/5)




Community Answers

  1. Hey guys, i am trying to create a box to show images or content once a user selects a link within a gallery. So for example i have an image --> user scrolls over --> image overlay shows a link ---> link actions to a jquery action to where a hidden field shows more data. right now i have everything to the point to where the links default action is disabled and the "overlay" div that will show the content is hidden. when i then go ahead and add some jquery to add a class when the link is clicked nothing seems to happen. <section class="work_area" id="WORK"> <div class="container"> <div class="row"> <div class="col-md-12 text-center"> <div class="work_title wow fadeInUp animated"> <h1>demo<span style="color: #64bdec; font-weight: bolder;">33</span> PORTFOLIO</h1> <img src="images/arrow486.png" alt=""> </div> <div id="dataBox"></div> </div> </div> </div> <div class="container-fluid"> <div class="row"> <div class="col-md-2 no_padding"> <div class="single_image"> <img src="images/REGISTERE.png" alt=""> <div class="image_overlay"> <h2>Lorem ipsum</h4> <a id="link" href="portfolio.php" >Popup link</a> </div> </div> </div> </div> </div> </section> CSS #dataBox{ width: 800px; height: 500px; margin: auto; padding: 100px 100px; position: relative; border: 2px solid black; margin-bottom: 10px; } #pData{ background: red; width: 800px; height: 500px; margin: auto; padding: 100px 100px; position: relative; border: 2px solid black; } JS. $(document).ready(function(){ $('#dataBox').hide(); $('#link').click(function(e){ e.preventDefault(); $('div #dataBox').removeClass().addClass('pData'); console.log("link is working"); }); }); everything works other than the div showing up.
  2. Yes everything was correct. It now seems to work flawlessly. seems there was a hiccup in the mail server, and all the requests / response got batched and sent together. so i think the code ( which it should ) works fine. i think this was more of an email server issue.
  3. Thanks for the feedback Requinix. I used a mail function library and installed this into my site. ( i added the following code into a file called mailtest.php ) ran it and success, i got my test email sent to me and everything was all good. I then tried to add this into my existing ( working ) php contact form that uses jquery and ajax to run a no refresh UI form. the form worked and all the functions ran perfectly. So i assumed just adding the code that worked inside one file would work inside my working conditional of the "completed" form. Does not seem to work . Not sure why the email wont go out anymore. php file that the ajax / jquery is taking from. <?php sleep(3); $name = trim($_POST['name']); $email = trim($_POST['email']); $subject = trim($_POST['subject']); $message = trim($_POST['message']); $honeypot = $_POST['honeypot']; $humancheck = $_POST['humancheck']; if ($honeypot == 'http://' && empty($humancheck)){ /// RUN SPAMBOT CHECK AND IF PASS CHECK TO MAKE SURE ALL FIELDS ARE OK $errorMsg = ''; $reg_exp = "/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/"; if(!preg_match($reg_exp, $email)){ $errorMsg .= "<p>A valid email is required</p>"; } if(empty($name)){ $errorMsg .= '<p>Please provide your name</p>'; } if(!isset($message)){ $errorMsg .= '<p>Please provide a message</p>'; print_r($_POST); } if(!empty($errorMsg)){ // IF NO ERRORS AND PASSES ARE ALL CHECKED , CONFIRM AND SEND EMAIL $return['error'] = true; $return['msg'] = 'Sorry the request was successful but your form was not correctly filled. ' . $errorMsg; echo json_encode($return); exit(); }else{ // SEND EMAIL TO CLIENT // ADD FOLDER FOR MAIL LIBRARY require 'PHPMailer-master/PHPMailerAutoload.php'; // BEGIN TO DEFINE EMAIL VARIABLES $mail = new PHPMailer; //$mail->SMTPDebug = 3; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.mandrillapp.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'MYusername'; // SMTP username $mail->Password = 'hidden_pass'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to $mail->From = "myemail@domain.com"; $mail->FromName = "DO-NOT REPLY"; $mail->AddAddress($email); $mail->Subject = "First PHPMailer Message"; $mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer."; $mail->WordWrap = 50; if($mail->Send()) { $return['error'] = false; $return['msg'] = '<h4>' . $name . ', thank you for your email.</h4> Your email from: ' . $email.' has been sent and one of our team members will contact you shortly..'; echo json_encode($return); } else { $return['error'] = true; $return['msg'] = 'THE EMAIL WAS NOT SENT .. PLEASE TRY AGAIN'; echo json_encode($return); } } } else { $return['error'] = true; $return['msg'] = 'Oops...there was a problem with your submission. Please try again' ; echo json_encode($return); } ?> Again, the mail() function works when i load it outside the conditional. but then in checking the conditional, it works within the PHP script and executes properly (displaying, that the user is submitting and validating from correctly. $return['msg'] = '<h4>' . $name . ', thank you for your email.</h4> Your email from: ' . $email.' has been sent and one of our team members will contact you shortly..'; They just dont seem to work together ?? any suggestions ?
  4. hey guys, i am trying to auto generate an email. i have a function that calls for the following use of : <?php $emailSub = 'Test Subject'; $emailTo = 'myemail@gmail.com'; $emailMsg = 'You have a new email that must be read below:<br> '; mail($emailTo,$emailSub,$emailMsg); ?> i dont seem to get any email. any suggestions as to why ?
  5. So the issue that was bringing this message was my regular expression variable was missing a character so the function of match was not working. $reg_exp = "/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$/ "; if(!preg_match($reg_exp, $email)){ $errorMsg .= "<p>A valid email is required</p>"; } so that fixed this issue. What you bring up is a whole other issue within itself, that i realized once solving the problem above. The data for $message is not being sent to with the submission and client side php is not seeing that data. Not sure why that would be happening. EDIT: I changed the if(empty($message)) -> if(!isset($message)) and that seemed to have fixed it. Any reason why that would be ?
  6. I changed this just in case that was the issue. nothing was solved. this was a great catch on the variable names, sadly i had shortcut the duplication of them and did not change them to the proper variable name. Nether of these solutions solved the problem. The actual processing of the script is taking longer ( i see the loading gif longer ) , but the final result is the same error. Any other suggestions ?
  7. Hey guys, i am trying to create a contact form that by passes the page refresh and uses Jquery and Ajax to direct to a php file server side. So far i have everything work fine. until the final part where i pass the json data type into PHP and look to catch an error, success, or completion value. Currently i have an error coming back with the following: SyntaxError: Unexpected token < error due to a parsererror condition I do not see any errors in the console of of chrome, and i have no idea why i am getting this syntax error. These does not seem to be any conflicting data going into the json or out to php. really been stuck on this for a day now This is my .js file $(document).ready(function(){ $('form #alertMessage').hide(); $('#submit').click(function(e){ e.preventDefault(); var valid = ''; var name = $('form #name').val(); var email = $('form #email').val(); var subject = $('form #subject').val(); var message = $('form #message').val(); var honeypot = $('form #honeypot').val(); var humancheck = $('form #humancheck').val(); if(name = '' || name.length <= 5 ){ valid += '<p>Sorry, Your name is required!</p> '; } if(!email.match( /^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/ )){ valid += '<p>A Valid Email is required</p> '; } if(subject = '' || subject.length <= 2 ){ valid += '<p>A Valid name is required</p> '; } if(message = '' || message.length <= 5 ){ valid += '<p>A brief description of you is required.</p> '; } if(honeypot != 'http://'){ valid += '<p>Sorry spambots not allowed.</p> '; } if(humancheck != ''){ valid += '<p>Sorry only humans allowed past this point.</p> '; } if(valid != ""){ $('form #alertMessage').removeClass().addClass('error') .html('<br><br>' + valid).fadeIn('fast') }else{ $('form #alertMessage').removeClass().addClass('processing') .html('<br><br>We are processing your form now...').fadeIn('fast') var formData = $('form').serialize(); submitForm(formData); } }); }); function submitForm(formData){ $.ajax({ type: 'POST', url: 'feedback.php', data: formData, dataType: 'json', cache: false, timeout: 7000, success: function(data){ $('form #alertMessage').removeClass().addClass((data.error === true) ? 'error' : 'success' ) .html(data.msg).fadeIn('fast'); if($('form #alertMessage').hasClass('success')){ setTimeout("$('form $alertMessage').fadeOut('fast')", 5000); } }, error: function(XMLHttpRequest, testStatus, errorThrown){ $('form #alertMessage').removeClass().addClass('error') .html(' <p>There was an ' + errorThrown + ' error due to a ' + testStatus + ' condition.</p>').fadeIn('fast'); }, complete: function(XMLHttpRequest, status){ $('form')[0].reset(); } }); }; Here is the php script. <? sleep(3); $name = trim($_POST['name']); $name = trim($_POST['email']); $name = trim($_POST['subject']); $name = trim($_POST['message']); $name = $_POST['honeypot']; $name = $_POST['humancheck']; if ($honeypot == 'http://' && empty($humancheck)){ $errorMsg = ''; $reg_exp = "/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$/ "; if(!preg_match($reg_exp, $email)){ $errorMsg .= "<p>A valid email is required</p>"; } if(empty($name)]){ $errorMsg .= '<p>Please provide your name</p>'; } if(empty($message)]){ $errorMsg .= '<p>Please provide a message</p>'; } if(!empty($errorMsg)){ $return['error'] = true; $return['msg'] = 'Sorry the request was successful but your form was not correctly filled.' . $errorMsg; echo json_encode($return); exit(); }else{ $return['error'] = false; $return['msg'] = 'Thank you for your feedback ' .$name . ' ' . $errorMsg; echo json_encode($return); } } else { $return['error'] = true; $return['msg'] = 'Oops...there was a problem with your submission. Please try again' ; echo json_encode($return); } ?> HTML side. <form id="contact_us" class="contact-form" action="feedback.php" enctype="multipart/form-data" method="post"> <div id="alertMessage"> </div> <div class="row"> <div class="col-md-6"> <input type="text" name='name' class="form-control" id="name" placeholder="Full Name"> <input type="email" name='email' class="form-control" id="email" placeholder="Your Email"> <input type="text" name='subject' class="form-control" id="subject" placeholder="Company or Project name"> </div> <div class="col-md-6"> <textarea class="form-control" name="text" id="message" rows="25" cols="10" placeholder=" Brief Description"></textarea> <input id='submit' name='submit' type="submit" class="btn btn-default submit-btn form_submit"> </div> <input type="hidden" name="honeypot" id="honeypot" value="http://" /> <input type="hidden" name="humancheck" id="humancheck" value="" /> </div> </form> Image of the error output
  8. //CHECK TO SEE IF TABLE ALREADY EXISTS TO THE DATE if($TABLE_NAME == $date){ // IF EXISTS THEN DROP THE TABLE echo 'THIS DATE ALREADY EXISTS <br>'; $drop_table = "DROP TABLE` " .$date."`"; mysql_query($drop_table); echo '<h4>THE TABLE HAS BEEN DROPPED</h4><h5>NOW SELECT THE FILE YOU WANT TO CREATE</h5>'; } else{ // CREATE THE NEW TABLE $create_table = "CREATE TABLE `".$date."` ( `entry_id` int(11) NOT NULL, `transaction_id` varchar(55) NOT NULL, `name` varchar(255) character set latin1 default NULL, `price` varchar(11) character set latin1 default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8"; mysql_query($create_table); echo 'NEW TABLE HAS BEEN CREATED PLEASE MOVE TO NEXT STEP'; } $run_q = mysql_query($create_table); $return = '<h4>FILE THAT YOU SELECTED:</h4>' . $_FILES['file']['name']; $file = $_FILES['file']['tmp_name']; $handle = fopen($file,"r"); while(($fileop = fgetcsv($handle,1000,",")) !== false){ $name = $fileop[0]; $price = $fileop[1]; $t_id = $fileop[2]; $ship_method = ''; $cc = ''; $address = ''; $city = ''; $state = ''; $cc = ''; $email = ''; $p_name = ''; $p_quantity = ''; $total = ''; $id = ''; $date = ''; } I can't seem to get the DROP TABLE query to execute through PHP. It is not a multiple query or anything that would create confusion, and when imputed into SQL directly fire correctly. Any suggestions ?
  9. Hey guys, Both great answers and very helpful. I am gonna mark boompa as the correct answer , simply for me it was a bit more helpful. Thank guys very much appreciated.
  10. $create_table = "SET FOREIGN_KEY_CHECKS=0; DROP TABLE IF EXISTS `" .$date."`; CREATE TABLE `".$date."` ( `transaction_id` varchar(11) NOT NULL, `name` varchar(255) character set latin1 default NULL, `price` varchar(255) character set latin1 default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8"; $run_query = mysql_query($create_table); Ok so i am some what confused as to why my table is not being created with this. When I insert the query directly into SQL the table is created with no error or issue. So i know the statement is true and syntax is not an issue. When i create the variable in PHP with the same query, then try to run the query, the same table is then not created in the DB. Am i missing a step ? usually this is pretty straight forward when working with DB. I would usually grab the data then fetch the array, then extract the data into a set of variables. Any suggestions ?
  11. Hey guys, I am learning some basic OOP rules and application right now. I was trying to understand setting a property inside of an object. $name = $_GET['user']; if(isset($name)){ class BankAccount{ public $balance = 3500; public function DisplayBalance(){ return $name . ' your Balance Currently is: ' .$this->balance; } public function Withdraw($amount){ $balance = $this->balance; if($balance < $amount){ $this->balance = 'Sorry you can\'t withdraw any funds right now, not enough to cover amount request of: $' .$amount . '. '; } else{ $this->balance = $this->balance-$amount; } } } So here i am trying to add an extra property into this class by grabbing the variable of $name, which is a dynamic string given from a user submit form. When i add public $user = $name; || $user = $name; I get an error, so my syntax is wrong So ultimately my question is, how do i correctly add the variable of $name into my class ? thanks guys,
  12. Hey Guys, so i made some progress on what i am trying to accomplish here but i still have a couple issues at hand that i cant seem to figure out. $current_file = explode('/', $_SERVER['SCRIPT_NAME']); $current_file = end($current_file); $timestamp = microtime(); $cache_dir = 'cache'; function cache_key($current_file,$cache_dir){ $pages_with_no_id = array('index.php'); $pages_with_id = array('watch.php','browse.php'); if(in_array($current_file, $pages_with_no_id)){ $cache_key = md5($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING']); }elseif(in_array($current_file,$pages_with_id)){ $cache_key = md5($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . $_GET); } $file = $cache_key. '.php'; return $file; } $file = cache_key($current_file,$cache_dir); $dir_file = $cache_dir .'/'.$file; $include = '\''.$dir_file.'\''; $handle = opendir('cache'); if(file_exists($dir_file)){ include $include; } else { $file_handler = fopen($dir_file,'w+') or die('error writting new file'); } closedir($handle); So now i have setup each page with a key and being set into my cache folder , now if a file exists in the folder already it will just include that file , if not then it should create that file from new. My main issues are 2 things: I want to now under the else condition when the new file has been created, i want to insert the content of the already created page into the cache page. so essentially after: $file_handler = fopen($dir_file,'w+') or die('error writting new file'); i want to then add something to this extent: fwrite($file_handler, $content); but i am not sure how to get the variable $content with the data of the entire page that i want cached; my second issue is: How do i approach adding the timestamp to the content page so that i can match the timestamp to new caches or update cache. ? Any Suggestions would be huge guys, I am doing my best to get this solved, but any push would help.
  13. i am getting these numbers logged by various website sources , the owner of the server doing times noticed that the website was running extremely slow compared to how the server was comparing, he himself told me the best thing to do would be to dynamically parse the data that is being viewed by multiple users at once. The website is running at 13 seconds compares to avg of 3-4 seconds . i am running 8 queries not including user signing in and grabbing user_data query for gathering sessions and user ID. no i have 15 logo or social media images, and content images that are being generated from amazon web are directly into markup via a function inserting md5 hash convert into url . but that is working at a very efficient speed other websites co-workers are running simultaneously. so i am certain it is my data being downloaded over and over. instead of server sending the stored cache or the website not even dealing with the server and just outputting the correct content
  14. Hey mac, thanks for the feedback, so let just say i am taking my index page, with about 60 images all dynamic in terms of content being updated by votes , ratiing , newly inserted. .. so these images many of them stay on the site for days , weeks, sometimes even never changing due to popularity. 45 of these images are from database sources from a table i have and those images are being pulled from an amazon web server. 15 of them are on file through the server none of the images is larger than 30kb ( logo ) and the avg is around 17- 18 KB. in terms of total mock-up size of the page its about 3.24 MB thanks again mac
  15. Hey Guys, So Currently i have a website that was my first web development project ( learning how to program and web design ). That now has generated a good amount of traffic and users, and although i am not greatly educated in Computer Science, i am learning my way to getting a better product to my end users. The problem: I see my bounce rate is not so well, and that my users are coming to a page that is slow in speed. The website handles images and text that are fed from queries to a database then spit out. Solution: My Users were coming on a page, and each user was having to load the same page and data over and over for each user. I learned that using a technique called dynamic caching that i would be able to solve this problem, by storing the query and data, then being able to feed that content one time to all the users who are viewing the site. This would accelerate your web speed dramatically. So i understand what my problem is and what the solution is. Now my Issue: I don't fully understand how to implement this from what i keep reading and researching on. I do know your suppose to work with ob() function which would help with buffering on the website. My problem is that from the beginning i was using ob_start() on the header of my website due to redirect issues when i would use header(). To be honest i didn't fully understand why using ob_start solved that issue but now i find myself having problems again with the error of : header has already been sent. I tried looking into platforms like Varnish or phpfastcache which led to some issues due to my lack of OOP progamming skill and was not able to solve this issue. I then tired to create a simple code that would create a cache for the page that the user was on. Store that data in tmp file then look for that file when a user first comes on, if they find that file in say 5 min span load that file, if not load a new one. All in all i think i am just failing at this due to my lack of understanding the core concept of what i am actually trying to do. what i have so far: function cache_file() { // something to (hopefully) uniquely identify the resource $cache_key = md5($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING']); $cache_dir = '/tmp/phpcache'; $cache_combo = $cache_dir . '/' . $cache_key; return $cache_combo; } $cache_file = cache_file(); echo $cache_file; die(); RESULTING IN : ISSUE : I AM NOT RETURNING A QUERY STRING, I UNDERSTAND SOMETIMES ONE WONT BE PRESENT AND I AM NOT SURE IF THIS IS EVEN A PROBLEM. So now each page is returning its own $cache_result // if we have a cache file, deliver it if( is_file( $cache_file = cache_file() ) ) { readfile( $cache_file ); exit; } else { echo 'NO FILE FOUND START A NEW 1'; } ISSUE : NO FILE IS BEING FOUND SO THE CONDITIONAL IS NOT PASSING AS TRUE FOR is_file() // cache via output buffering, with callback ob_start( 'cache_output' ); ISSUE : UNLESS ob_start() IS THE FIRST THING OFF MY CODE I GET THE HEADER RELOCATE ERROR OF: so if i have something like: echo cache_file(); ob_start(); resulting in: // // expensive processing happens here, along with page output. // Now at this point here i am guessing that i need to return the temp file and the content specific to the data return of the cache. I have been struggling to get the cache to setup correctly i have not even dealt with this part yet. I am somewhat lost on what is meant by expensive processing, i am assuming this is the part that takes all the server speed and processing that is needed for you to host with speed. All feedback and suggestions are very much appreciated, i am not so much looking for a answer per say, i would just like to get a better idea if i am on the right track , or what i am lacking or missing fundamentally or just code wise. thanks guys -Justin7410
  • 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.