Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hi All, I'm looking to update a mysql column weekly, where by 5 randomly selected rows are given a new random number, from between 1 and the num_rows / 5. This cycle is looped again until all the entries have a new random group for the week. It is to help mix up the players for teams for 5 aside. It needs to be able to accomodate the posibillity of the num_rows not dividing exactly by 5, using ceil perhaps? As an example Name Group a 1 b 2 c 1 d 1 e 1 f 3 g 2 h 1 i 2 j 2 k 2 Then Next week Name Group a 2 b 1 c 2 d 2 e 1 f 2 g 3 h 1 i 2 j 1 k 1 I hope that makes sense. It'll be automated via cron job. I've been really struggling with it, this is as far as I have got. $totalgroupsraw = $num_rows /5; $totalgroups = ceil ($totalgroupsraw); $i = 1; while ($i<$totalgroups) { $pie = mysql_query("UPDATE table SET columnname=5 order by rand() LIMIT 5"); $i++; }; But as you will no doubt be able to see, this doesn't work well at all. I think I am close, but I just can't seem to sort out a good way to do it. Any help much appreciated. Thanks, Matt
  2. Hi, I'm using $clid = mysqli_real_escape_string ($dbcon, $_POST['clid']); but have come across an issue with certain characters, for example: "bekæ" actually searches for "bekæ", hence no records. The records cannot be changed in the table, so is there a way to fix this?
  3. Good morning, I am trying to convert a mssql query into json format so that I can then later pass this through google's visualisation api. The query and encoding seems to be working but the encode returns NULL. I have checked the normal gotcha's of making sure its utf8 encoded and that I have used a version of PHP that has the encode (using php 5.3.19). Can any one help me with getting the encode to work. PHP CODE: <?php //connection and database details (known to be working) if( $conn ) { echo "Connection established.<br><br>"; }else{ echo "Connection could not be established.<br />"; die( print_r( sqlsrv_errors(), true)); } $query = "SELECT * FROM tblProducts"; $result = sqlsrv_query( $conn, $query); while( $row = sqlsrv_fetch_array( $result, SQLSRV_FETCH_NUMERIC) ); $arr = array($result); $encodedarray = array_map(utf8_encode, $arr); echo json_encode($encodedarray); sqlsrv_close( $conn); ?> When I run this code on the server it comes back with: Connection established. [null] Has anyone got any ideas of getting this to work? Thanks Kris
  4. Hello everyone, I run a small url shorting service. I have bought the script and everything which short long urls. And i want to use a php code in one of the pages. Let me explain you in detail first. My site is https://786.pw and user goes there and enter the long url and the short url becomes something like https://786.pw/shorturl ( for example) Now when this short url which is https://786.pw/shorturl is hit the user is redirected to the original long url. And thats how it is supposed to work. But in between i have the option to show a splash page which can be a advertisement or a timer or anything " The code of splash.php is :- <?php defined("APP") or die() // Media Page ?> <?php include_once("analyticstracking.php") ?> <section> <div class="container splash"> <?php echo $this->ads(728,FALSE) ?> <div class="row"> <div class="col-md-4 thumb"> <div class="panel panel-dark panel-body"> <img src="<?php echo $url->short ?>/i"> </div> </div> <div class="col-md-8"> <div class="panel panel-default panel-body"> <h2> <?php if (!empty($url->meta_title)): ?> <?php echo $url->meta_title ?> <?php else: ?> <?php echo e("You are about to be redirected to another page.") ?> <?php endif ?> </h2> <p class="description"> <?php if (!empty($url->meta_description)): ?> <?php echo $url->meta_description ?> <?php endif ?> </p> <br> <div class="row"> <div class="col-sm-6"> <a href="<?php echo $this->config["url"] ?>/?r=<?php echo base64_encode($url->url) ?>" class="btn btn-primary btn-block redirect" rel="nofollow"><?php echo e("Redirect me"); ?></a> </div> <div class="col-sm-6"> <a href="<?php echo $this->config["url"] ?>" class="btn btn-default btn-block" rel="nofollow"><?php echo e("Take me to your homepage") ?></a></a> </div> </div> <hr> <p class="disclaimer"> <?php echo e("You are about to be redirected to another page. We are not responsible for the content of that page or the consequences it may have on you.") ?> </p> </div> </div> </div> </div> </section> Now, I want to add solve media php script in it. Which means any user who is using our url shortner service needs to complete the captcha before he can be finally directed to the destination url. The script supports solvemedia captcha solving. I spoke to the creator of this script and he told me this. "You will need to have some basic php knowledge to achieve this. To add the catpcha you need to use <?php echo Main::captcha() ?> which will echo the captcha To validate the result you need to use <?php if(Main::check_captcha($_POST) == "ok") { // If captcha is ok do something here }else{ // else do something here } ?> " I dont have any php knoweldge., How can i enter this code in splash.php in order to show the captcha ? Please suggest. And ask any question if you need
  5. Hello, I'm finishing a content manager, but I have a little problem with a iframe. Let me explain: I have a url stored in a table in a database, which is the path to a page called "galeria.php", which is a dynamic gallery. This gallery is loaded on the site when the user clicks on a submenu button called "portfolio". The iframe loads the gallery when clicked the "portfolio" button. So far so good. Loads exactly when and how I want. The problem is that when we are not on the "portfolio" page, the iframe keeps the occupation of space, even having no content. This causes on the website, unnecessary scroll. In practice what I ask, is how to do that when the iframe has no content, it becomes "hidden" or not take up space on the page. Thank you
  6. So i have this following code that doesn't work <?php $id = $_GET['id']; $data = $_GET['data']; $key = "Password"; mysql_query("update contest_data set '$key'='$data' where Contest_Data_ID='$id'") ?> it doesn't work unless i put it like this <?php $id = $_GET['id']; $data = $_GET['data']; $key = "Password"; mysql_query("update contest_data set `Password`='$data' where Contest_Data_ID='$id'") ?> is there a way to put the `` when setting the $key value i even tired to put $key = "`Password`" and that doesn't work. Also $key="password" is going to be $key= $_GET['key'] but for now i put it like this so i can test it out
  7. I would like to send an email when % is >than 50%, if so get fields from Txt fiel and fields from DB and send an email to the address in the txt file. <html> <head><title>Email Alert</title></head> <body> <?php require 'PHPMailerAutoload.php'; $mail = new PHPMailer; //$mail->SMTPDebug = 3; // Enable verbose debug output mysql_connect("ip","user","pass") or die(mysql_error()); //mysql_select_db("DB") or die(mysql_error()); //$sql = "SELECT * from pool"; $sql = mysql_db_query ("demo", "select * from pool "); while ($row = mysql_fetch_assoc($sql)) { $sql = "SELECT '%' FROM pool Where >= 50 "; { //echo $row->number; $percent = $row['%'] ; $pool2 = $row['pool']; $balance = $row['balance']; /////////////////////////// //data from file ////////// ////////////////////////// $file = fopen('EmailAndPool2.csv', 'r'); $fields = array(); if ($file) { while (($data = fgetcsv($file)) !== false) { if(empty($fields)) { $fields = $data; continue; } $row = array_combine($fields, $data); // Format output conveniently with sprintf $output = sprintf("%s Pool %s email.\n", $row['pool'], $row['email']); echo $output; } fclose($file); $pool1 = $row['pool']; //while ($pool2 == $pool1 and $percent > "50") $pool2 =$row['pool2']; $mail = new PHPMailer; $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'xxxxxxxxx; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'xxxxxxxxxxxxxxxxx'; // SMTP username $mail->Password = 'xxxxxxxxxxxxxxxx; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to $mail->FromName = 'Support'; $mail->addAddress ($row['email']); //$mail->addAddress = $members; //$mail->addCC('xxxxxxxxxxx'); //$mail->addCC('xxxxxxxxxxxxxxxx'); $mail->WordWrap = 50; // Set word wrap to 50 characters $mail->isHTML(true); $mail->Subject = 'test'; $mail->Body = 'test '; $email_from = 'xxxxxxxxxxxx'; } if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent'; } } } ?> </body> </html> Thank you
  8. I know the title is a bit confusing but I wasn't exactly sure how to describe my issue and none of my numerous searches online and here returned any positive results for a solution. What I'm trying to do is allow a user to 'choose' one set from multiple sets of numbers for inclusion into the database. The image below should with the visualization of my goal. As you can see from the above image, there's a "button" to the right that states "keep this set". My goal is to allow the user to click the button and the corresponding set of values is then entered into the database as a string (the values aren't being used in any calculations afterwards just being displayed on screen.) The following code below works for auto-insertion if there's only one set generated but nothing I've attempted so far works when it comes to allowing the user to choose one set they'd like entered. <?php additional code here... echo '<table><tr><td>'; for($i=1; $i<=$Sets; $i++){ $Stat_Results = GenStats($uId, $StartSet, $SetOption); echo "Stat values for ".$SetGenerated[$i]; foreach($Stat_Results as $key => $DisplayStats){ echo $DisplayStats.', '; } if($Sets == 1){ $SetResults = implode(',',$Stat_Results); DB_Insert($uId, $SetResults, $TimeStamp); }else if($Sets >= 2){ echo "</td><td> => <input type='button' name='submit' value='keep this set'></td> <tr><td>"; } } echo '</td></tr></table>'; ?> html below here.... Variables: $sId, $StartSet, $SetOption, $Sets, $uId, and $TimeStamp are all set in a section not shown in this snippet. I've tried Javascript but too be honest, I'm not all that familiar with it (though I am trying to become more fluid in it) and I've went so far as to try to create the multiple sets as a dropdown box thinking the user could simply select it from there and it be treated as a dynamic form and php would do the rest. But that didn't work either. The form button for submission is the remnant of the <select> list I tried to generate. The form is no longer there. I left the button in to generate the image you see above and has since been removed from the actual code. I admit, I'm stuck and need some guidance because I can't seem to make this work no matter what I do. I realize $Stat_Results is a multidimensional array and contains all the values of each set in their respective array, but so far, I'm at a stand still on properly retrieving those values for insertion. Thanks to all who read and attempt to help!
  9. I am in the process of creating a script where only certains video types can be uploaded but at the moment am stuck. Here is my code - <?php $title = isset($_POST['title']) ? $_POST['title'] : null; $desc = nl2br(isset($_POST['description'])) ? $_POST['description'] : null; $name = isset($_POST['fullname']) ? $_POST['fullname'] : null; $email = isset($_POST['email']) ? $_POST['email'] : null; $country = isset($_POST['country']) ? $_POST['country'] : null; $video = isset($_FILES['video']); $videoname = isset($_FILES['video']['name']); $videotmp = isset($_FILES['video']['tmp_name']); $videosize = isset($_FILES['video']['size']); $videotype = isset($_FILES['video']['type']); $videoacceptable = array( "video/mp4", "video/ogg", "video/quicktime", ); $videopath = "/videos/"; $videofile = $videopath . $video; if(isset($_POST['submit'])) { //ERROR MESSAGES / VALIDATION if(empty($title)) { $errors[] = "A title is required"; echo "<style type=\"text/css\"> #title { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } elseif(strlen($title) > 80) { $errors[] = "Your title can only be 80 characters long"; echo "<style type=\"text/css\"> #title { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } if(empty($desc)) { $errors[] = "A description is required"; echo "<style type=\"text/css\"> #description { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } if(empty($name)) { $errors[] = "Please enter your full name"; echo "<style type=\"text/css\"> #fullname { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } elseif(strlen($name) > 32) { $errors[] = "Your name can only be 32 characters long"; echo "<style type=\"text/css\"> #fullname { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } if(empty($email)) { $errors[] = "Please enter your email address"; echo "<style type=\"text/css\"> #email { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } elseif(strlen($email) > 50) { $errors[] = "Your email addess can only be 50 characters long"; echo "<style type=\"text/css\"> #email { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors[] = "Please enter a valid email address"; echo "<style type=\"text/css\"> #email { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } if($videosize = 0) { $errors[] = "You forgot to upload a video"; } elseif($videosize >= 20000000) { $errors[] = "Your video size is too large, 20mb max"; } elseif(!in_array($videotype, $videoacceptable)) { $errors[] = "The file type is not allowed, only allowed .mp4, .ogg and .mov"; } if(count($errors) === 0) { $connect = mysqli_connect("localhost","username","password"); if(!$connect) { header("Location:"); // ADD ERROR LINK } $dbselect = mysqli_select_db("database"); if(!$dbselect) { header("Location:"); // ADD ERROR LINK } $query = mysqli_query("INSERT INTO cover_videos(title, desc, name, email, country, videotmp, videotype, videosize, videopath) VALUES('$title','$desc','$name','$email','$country','$videotmp','$videotype','$videosize','$videopath')"); move_uploaded_file($videotmp, $videofile); //SEND AN EMAIL TO THE USER $to = $email; $subject = "Thank's for your upload"; $message = ' <html> <head><title>We have received your video</title></head> <body> <h3>Good News!</h3> <p>We have recieved your video and is awaiting approval.</p> </body> </html> '; $headers = 'FROM: no-replyk' . "\r\n"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers = 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); header("Location:"); //SUCCESSFUL UPLOAD PAGE } } ?> So whats happening is when i go to upload a file, im uploading a .mov file but the error message that pops up is "The file type is not allowed, only allowed .mp4, .ogg and .mov" but the .mov mime is in the videoacceptable array so im a bit stuck at the moment, any know whats the problem?
  10. Hi I have a form that has a drop-down with a few to choose from, unfortunately I don't get results for some due to the query involved. Some need the AND channel LIKE '%$channel%'"; and some don't and therefore will not get desired results. So I would like to run two queries one with and one without. $query = "SELECT * FROM asterisk_cdr WHERE calldate BETWEEN '$calldate' AND '$calldate2' AND clid LIKE '%$clid%' AND channel LIKE '%$channel%'"; Thanks
  11. everytime i run my code i get ( ! ) Warning: mysqli_query() expects parameter 2 to be string, object given in C:\wamp\www\Tutorial\test.php on line 5. i just cant seem to find the error my code looks like this test.php
  12. I am building an e-commerce site and I am aiming to create a front end displaying my products with an option for customers to buy them, and have a content management system as a back end for an admin to edit product information. Currently I am storing information about my products on a mysql database. I access and display the product info using a while loop. Below is a simplified version of what I am doing without any html to style it. This code will go through the database and each iteration will go the to the next row and display the info about the next product. $query = mysql_query("SELECT * FROM truffleProducts"); while ($row = mysql_fetch_array($query)) { $id = $row['id']; $name = $row{'Name'}; $price = $row{'Price'}; $desc = $row{'Description'}; echo $id; echo $name; echo $price; echo $desc; } I have began to implement a 'buy' button so that customers are able to click on a button next to the product info and purchase it. However I have come across a problem which is where my program won't be able to tell which product you have selected as the number stored in the $id variable will just be the last product it has fetched from the database. I can't differentiate between all the product's buy buttons, so it will impossible to place an order for a customer with the current system I have. Can any one tell me how to get the id number of the specific product that a user has selected? I only started learning PHP a month or two ago so assume I know nothing
  13. i am new with web socket and in same time I try to make server and client communication for soccer manager application, and for this purpose, i need to create closed "chat rooms" or "games" where two users can watch (read game event) and menage (create) game event (make substitution, formation ... or if you want, to send message to server, that they make changes in formation) this game (room) mast bi secret, and only this two player can use this game for "read" and "write" events in game for example: Game no: 200001 between user A and user B in 14.05. when User A, and User B click on game no. 200001 they can read and write game event. PS: for now, i create basic chat aplication with PHP, jQuery and webSocket and in this app, all user see wath all other user do (public chat) and i want to make secret chat for specific user (already automate subscribed from server) All work with no problem (i work on this example http://www.sanwebe.com/2013/05/chat-using-websocket-php-socket) How i can create chat room(s) and subscribe user to specific chat room? Thanks
  14. Hi Using: echo $row['columnname']; How can I strip off data from the above echo? The column always begins with 'Local/' then 3 digits then other unwanted data, lke 'Local/567@context-0000461d;1'. It would be ideal to just display '567'.
  15. I have mysql table titled fee_payment. details of the table: fee_payment Table payment_id student_id name class term year date amount 1 6 john JHS2 2nd_term 2013 23-04-2013 56 67 2 6 john JHS2 2nd_term 2013 23-04-2013 56 34 3 5 peter JHS3 3rd_term 2014 23-04-2014 56 85 4 6 john JHS2 2nd_term 2014 23-04-2014 56 76 5 6 john JHS2 3rd_term 2014 23-04-2014 56 34 6 6 john JHS2 2nd_term 2014 23-04-2014 56 23 7 5 peter JHS2 3rd_term 2014 23-04-2014 56 43 what i need to do now is to sum total amount paid by each student so that i can view payment records based on term and year. what i have tried: Controller: /******MANAGE FEE PAYMENTS / INVOICES WITH STATUS*****/ function payfees($param1 = '', $param2 = '', $param3 = '') { if ($this->session->userdata('admin_login') != 1) redirect(base_url(), 'refresh'); if ($param1 == 'create') { $data['student_id'] = $this->input->post('student_id'); $data['name'] = $this->input->post('name'); $data['class_id'] = $this->input->post('class'); $data['term'] = $this->input->post('term'); $data['year'] = $this->input->post('year'); $data['amount'] = $this->input->post('amount'); $data['creation_timestamp'] = strtotime($this->input->post('date')); $this->db->insert('fee_payment', $data); redirect(base_url() . 'index.php?admin/payfees', 'refresh'); } if ($param1 == 'do_update') { $data['student_id'] = $this->input->post('student_id'); $data['class_id'] = $this->input->post('class'); $data['term'] = $this->input->post('term'); $data['year'] = $this->input->post('year'); $data['amount'] = $this->input->post('amount'); $data['creation_timestamp'] = strtotime($this->input->post('date')); $this->db->where('payment_id', $param2); $this->db->update('fee_payment', $data); redirect(base_url() . 'index.php?admin/payfees', 'refresh'); } else if ($param1 == 'edit') { $page_data['edit_data'] = $this->db->get_where('fee_payment', array( 'payment_id' => $param2 ))->result_array(); } if ($param1 == 'delete') { $this->db->where('payment_id', $param2); $this->db->delete('fee_payment'); redirect(base_url() . 'index.php?admin/payfees', 'refresh'); } $page_data['page_name'] = 'payfees'; $page_data['page_title'] = get_phrase('fee_payment'); $this->db->order_by('creation_timestamp', 'term'); $page_data['payments'] = $this->db->get('fee_payment')->result_array(); $this->load->view('index', $page_data); } The Invoice: <div class="box-content"> <?php foreach($edit_data as $row):?> <div class="pull-left"> <span style="font-size:20px;font-weight:100;"> <?php echo get_phrase('payment_to');?> <img width="50" height="30" src="<?php echo base_url();?>uploads/logo.png" style="max-height:100px;margin:20px 0px;" /> </span> <br /> <?php echo $system_name;?> <br /> <?php echo $this->db->get_where('settings' , array('type'=>'address'))->row()->description;?> </div> <div class="pull-right"> <span style="font-size:20px;font-weight:100;"> <?php echo get_phrase('credited_account:');?> </span> <br /> <?php echo $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->name;?> <br /> <?php echo get_phrase('student_id');?> : <?php echo "FAVECSID0000", $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->student_id;?> <br /> <?php echo get_phrase('class');?> : <?php $class_id = $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->class_id; echo $this->db->get_where('class' , array('class_id'=>$class_id))->row()->name; ?> </div> <div style="clear:both;"></div> <hr /> <table width="100%" background="http://localhost/schoolmanager/uploads/backlogos.png"> <tr style="background-color:#7087A3; color:#fff; padding:5px;"> <td style="padding:5px;"><?php echo get_phrase('payment_details');?></td> <td width="30%" style="padding:5px;"> <div class="pull-right"> <?php echo get_phrase('amount');?> </div> </td> </tr> <tr> <td> <span style="font-size:20px;font-weight:100;"> <?php echo get_phrase('payment_made');?> </span> <br /> </td> <td width="30%" style="padding:5px;"> <div class="pull-right"> <span style="font-size:20px;font-weight:100;"> <?php echo "Gh", $row['amount'];?> </span> </div> </td> </tr> <tr> <tr> <td> <span style="font-size:20px;font-weight:100;"> <?php echo get_phrase('balance');?> </span> <br /> <?php echo $row['description'];?> <?php $exams = $this->db->get_where('fee_payment', array('student_id'=>$row['student_id']))->result_array(); foreach($exams as $row): ?> <?php $ttpaid = sum($row['amount']); echo $ttpaid;?> <?php endforeach; ?> </td> <td width="30%" style="padding:5px;"> <div class="pull-right"> <span style="font-size:20px;font-weight:100;"> <?php $tuition = $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->tuition_fee; $status = $this->db->get_where('student' , array('student_id'=>$row['student_id']))->row()->status_fee; $total_fees = $tuition + $status; $balance_fee = $total_fees - $row['amount']; echo "Gh", $balance_fee; ?> </span> </div> </td> </tr> <tr> <td></td> <td width="30%" style="padding:5px;"> <div class="pull-right"> <hr /> <?php echo get_phrase('status');?> : <?php echo $row['status'];?> <br /> <?php echo get_phrase('receipt_no:');?> : <?php echo "FAVECSFP0000",$row['payment_id'];?> <br /> <?php echo get_phrase('date');?> : <?php echo date('m/d/Y', $row['creation_timestamp']);?> </div> </td> </tr> </table> <br /> <br /> <?php endforeach;?> </div> </div> output: ayment To fffff P O BOX 126 Credited Account: john Student Id : FAVECSID00006 Class : JHS2A Payment Details Amount Payment Made Gh34 Balance as we can see, i am only able to fetch one payment made by john but not able to sum all amount that belong to john. please help. thank you in advance
  16. Hi, I'm looking for a programmer to fix my search engine script. If interested, please go to www.shoppersplace.com and check out the buffering, header, errors at the top of the page of this search engine. try a few searches and see the errors. thank you.
  17. I need to check whether the user has uploaded a file when submitting a form using isset. If they have, the file path is recorded to the database. If they haven't nothing needs to occur, the file path field will just be NULL. Here is my issue: When I test it with uploading no file I'm still getting "images/" from my $ filelocation variable recorded to the database. How can I fix this? <?php if(isset($_FILES['userfile'])) { $fileupload = $_FILES['userfile']['name']; $filetype = $_FILES['userfile']['type']; $filesize = $_FILES['userfile']['size']; $tempname = $_FILES['userfile']['tmp_name']; $filelocation = "images/$fileupload"; } else { $filelocation = NULL; } if (!move_uploaded_file($tempname,$filelocation)) { switch ($_FILES['userfile']['error']) { case UPLOAD_ERR_INI_SIZE: echo "<p>Error: File exceeds the maximum size limit set by the server</p>" ; break; case UPLOAD_ERR_FORM_SIZE: echo "<p>Error: File exceeds the maximum size limit set by the browser</p>" ; break; default: echo "<p>File could not be uploaded </p>" ; } } if ($_POST["productName"] == "") { header("Location:getProductDetails.php"); exit(); } elseif ($_POST["productDescription"] == "") { header("Location:getProductDetails.php"); exit(); } else { $conn = @mysqli_connect("localhost", "root", ""); if (!$conn) { echo "The connection has failed: " . mysqli_error($conn); } else { //echo "Successfully connected to mySQL!"; $query = "CREATE DATABASE IF NOT EXISTS bazaar"; $dbName =""; if (!mysqli_query($conn,$query)) { echo "<p>Could not open the database: " . mysqli_error($conn)."</p>"; } else { //echo "<p>Database successfully created</p>"; if (!mysqli_select_db($conn,"bazaar")) { echo "<p>Could not open the database: " . mysqli_error($conn)."</p>"; } else { //echo "<p>Database selection successful</p>"; $query = "CREATE TABLE IF NOT EXISTS products(productid int primary key not null auto_increment,productname varchar(50), productdesc text, colour varchar(25), price decimal(5,2) not null,imagepath varchar(250));"; if (!mysqli_query($conn,$query)) { echo "table query failed1: " . mysqli_error($conn); } else { //echo "<p>table query successful</p>"; $insert = "INSERT INTO products (productname, productdesc, colour, price, imagepath) VALUES ('$_POST[productName]','$_POST[productDescription]','$_POST[colour]','$_POST[price]','$filelocation');"; if (mysqli_query($conn,$insert)) { $customerId = mysqli_insert_id($conn); } else { echo "table query failed: " . mysqli_error($conn); } } } } } mysqli_close($conn); } ?>
  18. How can I move my intro text shown in step 2 to the same place in step 1? To see the intro text visit - http://www.workbooks.com/sales-performance-calculator and click "Get started now". Then click > Next step You'll see the text: >Over the next few steps we’ll ask you to rate your current sales and marketing performance and then estimate your future rating with a new CRM platform that meets your business needs and requirements. This is the text which I'd like to remove and add in the same place above the first step (Step 1 (of 7) - Current Business Figures. This line is found on line 9 in values.php see JSFiddle - http://jsfiddle.net/arf1z13w/ $wb_spc_array['sections'][] = array("key" => "new-business-generating", "name" => "New Business Generating", "type" => "sales", "intro" => "<p>Over the next few steps we’ll ask you to rate your current sales and marketing performance and then estimate your future rating with a new CRM platform that meets your business needs and requirements.</p>", "description" => "Rate your organisation on its ability to effectively market to new prospects, generate leads and then measure the ROI of marketing campaigns. We’ve outlined some positive and negative indicators below to provide you with a benchmark.", "body" => " The remainder of the page seems to be styled in wb_spc.module, see a JSFiddle of this - http://jsfiddle.net/bmzox5vL. How can I make this work?
  19. Hello, so I have input form for feedback with php mail send but i also want to send a sms message to user. This is html: <div class="fs-form-wrap" id="fs-form-wrap"> <form id="form" class="fs-form fs-form-full" action="#" method="post" autocomplete="off"> <ol class="fs-fields"> <li> <label class="fs-field-label fs-anim-upper" for=Name?</label> <input class="fs-anim-lower" id="q1" name="q1" type="text" placeholder="Name" required/> </li> <li> <label class="fs-field-label fs-anim-upper" for="q2" data-info="Vaild eamil....?</label> <input class="fs-anim-lower" id="q2" name="q2" type="email" placeholder="email@email.com" required/> </li> <li> <label class="fs-field-label fs-anim-upper" for="q3" data-info="Valid phone number">Phone number...?</label> <input onkeypress='return event.charCode >= 48 && event.charCode <= 57' class="fs-anim-lower" id="q3" name="q3" type="text" maxlength="10" placeholder="09x-xxx-xxxx" required/> </li> <li> <label class="fs-field-label fs-anim-upper" for="q4" data-info="What do you think about our servise?">Feedback</label> <textarea class="fs-anim-lower" id="q4" name="q4" placeholder="Feedback.."></textarea> </li> </ol><!-- /fs-fields --> <button class="fs-submit" type="submit" name="submit" id="send" >Send</button> </form> </div> This is php mail: <?php if(isset($_POST["submit"])){ //Checking for blank Fields.. if($_POST["q1"]==""||$_POST["q2"]==""||$_POST["q3"]==""||$_POST["q4"]==""){ echo "Fill everything.."; }else{ // Check if the "Sender's Email" input field is filled out $email=$_POST['q2']; // Sanitize e-mail address $email =filter_var($email, FILTER_SANITIZE_EMAIL); // Validate e-mail address $email= filter_var($email, FILTER_VALIDATE_EMAIL); if (!$email){ echo "Invalid Sender's Email"; } else{ $subject = $_POST['q3']; $message = 'Name: ' . $_POST['q1'] . ' Email: ' . $_POST['q2'] . ' Phone Number: ' . $_POST['q3'] . ' Feedback: ' . $_POST['q4']; $headers = 'From:'. $email . "\r\n"; // Sender's Email // message lines should not exceed 70 characters (PHP rule), so wrap it $message = wordwrap($message, 70); // Send mail by PHP Mail Function mail("myemail@mydomain.com", $subject, $message, $headers); echo "Thank you for feedback"; } } } ?> I have public sms getaway on my computer so when user input his phone script make link like this "http://mysmsgetaway.com?PhoneNumber=user-phone-number&Text=message-from-us" and it goes to my getaway.. Thank you
  20. Hi, I have results from a MySQL table column which does an echo into a table cell, but some of the results from the table column is be empty, so is there a way to fill in the blanks with text like "No data"?
  21. Hello guys! I'm currently writing a bit of an image gallery code which is working pretty well however there seems to be a few issues with the sytling and layout of the gallery. (It's nothing flash just displays the images and caption in category order) Now I am not sure how to go about doing this but is there any way to wrap each category in a div? I have the whole while loop wrapped in a div at present but I would like each category wrapped so I can style it a bit easier. Can someone please point me in the right direction. Currently my code looks like this: function Gallery(){ ini_set('display_errors',1); error_reporting(E_ALL); $conn = mysqli_connect("Why","Hello","There","Friends") or die('Cannot Connect to the database'); $q ="SELECT * FROM gallery_category AS c JOIN gallery_photos AS p ON p.categoryname = c.categoryname ORDER BY c.categoryid"; $result = mysqli_query($conn, $q) or trigger_error("Query Failed! SQL: $conn - Error: ".mysqli_error(), E_USER_ERROR); echo"<div class='gallery'>"; $categoryname=''; while($rows = mysqli_fetch_assoc($result)){ if ($categoryname != $rows['categoryname']) { $categoryname = $rows['categoryname']; echo"<div class='h'><h2>".$rows['categoryname']."</h2></div>"; } echo" <div class='gall'> <div class='gl-img'><img src='pathway/to/gallery/".$rows['photoname']."' alt='".$rows['categoryname']."'/></div> <div class='gl-cap'>".$rows['photocaption']."</div> </div>"; } echo"</div>"; $conn-> close(); } I don't know how to go about updating it so that it is this section that is wrapped whilst the "gall" class repeats (if that makes sense) echo"<div class='h'><h2>".$rows['categoryname']."</h2></div>"; } echo" <div class='gall'> <div class='gl-img'><img src='pathway/to/gallery/".$rows['photoname']."' alt='".$rows['categoryname']."'/></div> <div class='gl-cap'>".$rows['photocaption']."</div> </div>"; So that it looks like this: <div class="category"> <div class="h"><h2>Category Title</h2></div> <div class="gall"> <div class="gl-img"><img src="pathway/to/gallery/polarbear2.jpg"></div> <div class="gl-cap">Polar Bear</div> </div> <div class="gall"> <div class="gl-img"><img src="pathway/to/gallery/polarbear2.jpg"></div> <div class="gl-cap">Polar Bear</div> </div> <div class="gall"> <div class="gl-img"><img src="pathway/to/polarbear2.jpg"></div> <div class="gl-cap">Polar Bear</div> </div> <div class="gall"> <div class="gl-img"><img src="pathway/to/gallery/polarbear2.jpg"></div> <div class="gl-cap">Polar Bear</div> </div> </div> Any and all help on how to achieve this would be appreciated!! thank you
  22. Hi Guys I am fairly new to php, I am trying to build a registration form but I am struggling with encrypting the password (I will also be salting the password at a later stage to make it more secure). The below line of code encrypts the password but saves the values as the values states in the code e.g password saves as 'pass' $q = "INSERT INTO users (first_name,last_name,email,pass,registration_date) VALUES ('first_name','last_name','email', SHA1('pass'), NOW())"; The below code saves all the values that the user inputs xcept the password which is blank and the message 'Undefined index: SHA1('pass')' is returned $q = "INSERT INTO users (first_name,last_name,email,pass,registration_date) VALUES ('".$_POST["first_name"]."','".$_POST["last_name"]."','".$_POST["email"]."','".$_POST["SHA1('pass')"]."', NOW())"; I am hoping someone may be able to help me as I have no idea how to fix this. Thank you in advance
  23. Hello fellow programmers I recently bought a chat site without investigating (i know stupid me). this chat is made in Php / Mysql language and ajax, My question is, is there a possibility to convert the mysql to an IRC server. I dont know how to explane it 100% but is it possible to make the webchat thats coded in ajax & mysql work for a IRC server I have knowledge of mysql / php only is this above my level. My problem is that mysql is no option for chats, I need this webchat work with IRC but I have no idea where i should start. Maby someone can kick me in the right direction Thanks for your time & help Greets BTW this is the chatsite more people bought (this aint my site) but 100% the same : http://tinyurl.com/kk4gchd
  24. Just a bit of background first: I have a contact form set up on one of my domains. It hasn't been updated in 7 years and recently I started getting about 3-8 spam messages daily through it. At some point I updated other sites with code that includes a CAPTCHA. Out of sheer laziness, instead of recoding the contact form that was getting spammed, I just copied & pasted one of the updated forms and changed the necessary details like which e-mail address, URL, etc. Unfortunately, this hasn’t worked out properly. For some reason the CAPTCHA image isn’t being displayed. I keep looking but can't find the error(s). Could someone please take a look at the code and tell me what went wrong? I’d be ever so grateful for any help! The code for the form itself: <form method="post" action="mail-e.php"> <p><input type="text" name="name" id="name" value="who are you?" size="25" /></p> <p><input type="text" name="email" id="email" value="you@whatever.bla" size="25" /></p> <p><input type="text" name="url" id="url" value="http://" size="25" /></p> <p><textarea name="comments" id="comments" rows="1" cols="20">Go on, then. Tell me a story, wingy!</textarea></p> <p><img src="http://echoing.org/captcha.php" alt="humanity check" /><br /> <input type="text" name="captcha" id="captcha" /> <br /> <p><input type="submit" name="submit" id="submit" value="sing to me" /> <input type="reset" name="reset" id="reset" value="out of key" /></p> </form> mail-e.php: <?php session_start(); //Encrypt the posted code field and then compare with the stored key if(md5($_POST['captcha']) != $_SESSION['key']) { die("Error: You must enter the code correctly"); }else{ echo 'You entered the code correctly'; } ?> <?php if (!isset($_POST['submit'])) { include('./header.php'); echo "<h1>HEY!!! You just encountered an error!</h1>\n <p>You don't belong here. <strong>Because it's <em>wrong</em>.</strong> Go back and try again, please.</p>"; include('./footer.php'); exit; } function cleanUp($data) { $data = strip_tags($data); $data = trim(htmlentities($data)); return $data; } $name = cleanUp($_POST['name']); $email = cleanUp($_POST['email']); $url = cleanUp($_POST['url']); $comments = cleanUp($_POST['comments']); if ((empty($name)) || (empty($email)) || (empty($comments))) { include('./header.php'); echo "<h2>Input Error! Looks like you missed some stuff.</h2>\n <p><strong>Name</strong>, <strong>e-mail</strong> and <strong>comments</strong> are required fields. Please fill them in and try again:</p>"; echo "<form action=\"mail-e.php\" method=\"post\"><p>"; echo "<input type=\"text\" name=\"name\" id=\"name\" value=\"$name\" /> Name<br />"; echo "<input type=\"text\" name=\"email\" id=\"email\" value=\"$email\" /> E-mail<br />"; echo "<input type=\"text\" name=\"url\" id=\"url\" value=\"$url\" /> Site URL<br />"; echo "<textarea name=\"comments\" id=\"comments\">$comments</textarea> Comments<br />"; echo "<img src=\"http://echoing.org/captcha.php\" alt=\"humanity check\" style=\"margin-bottom: 2px;\" /><br />"; echo "<input type=\"text\" name=\"captcha\" id=\"captcha\" /> <br />"; echo "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Send\" />"; echo "</p></form>"; include('./footer.php'); exit; } if (!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$",$email)) { include('./header.php'); echo "<h2>Input Error</h2>\n <p>That e-mail address you entered - \"$email\" - is <em>not</em> a valid electronic address. Please edit it and send it in again, please:</p>"; echo "<form action=\"mail-e.php\" method=\"post\"><p>"; echo "<input type=\"text\" name=\"name\" id=\"name\" value=\"$name\" /> Name<br />"; echo "<input type=\"text\" name=\"email\" id=\"email\" value=\"$email\" /> E-mail<br />"; echo "<input type=\"text\" name=\"url\" id=\"url\" value=\"$url\" /> Site URL<br />"; echo "<textarea name=\"comments\" id=\"comments\">$comments</textarea> Comments<br />"; echo "<img src=\"captcha.php\" alt=\"humanity check\" style=\"margin-bottom: 2px;\" /><br />"; echo "<input type=\"text\" name=\"captcha\" id=\"captcha\" /> <br />"; echo "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Send\" />"; echo "</p></form>"; include('./footer.php'); exit; } $email = preg_replace("([\r\n])", "", $email); $find = "/(content-type|bcc:|cc:)/i"; if (preg_match($find, $name) || preg_match($find, $email) || preg_match($find, $url) || preg_match($find, $comments)) { include('./header.php'); echo "<h1>Error</h1>\n <p>No meta/header injections, please.</p>"; include('./footer.php'); exit; } $recipient = "my email address is here"; $subject = "paint me a wish on a velvet sky"; $message = "Name: $name \n"; $message .= "E-mail: $email \n"; $message .= "URL: $url \n"; $message .= "Comments: $comments"; $headers = "From: a wish painted on the velvet sky \r\n"; $headers .= "Reply-To: $email"; if (mail($recipient,$subject,$message,$headers)) { include('./header.php'); echo "<<p>WOO HOO! Your message was successfully sent to me! I'll read it as soon as I can. I may even respond! Thanks for using the form, fruitcake </p>"; include('./footer.php'); } else { include('./header.php'); echo "<p>Something went awry. Your message didn't go through. Want to take another crack at it? Please do, I'd love to hear from you!</p>"; include('./footer.php'); } ?> captcha.php: <?php //Start the session so we can store what the code actually is. session_start(); //Now lets use md5 to generate a totally random string $md5 = md5(microtime() * mktime()); /* We dont need a 32 character long string so we trim it down to 5 */ $string = substr($md5,0,5); /* Now for the GD stuff, for ease of use lets create the image from a background image. */ $captcha = imagecreatefromjpeg("http://echoing.org/captcha.jpg"); /* Lets set the colours, the colour $line is used to generate lines. Using a blue misty colours. The colour codes are in RGB */ $black = imagecolorallocate($captcha, 0, 0, 0); $line = imagecolorallocate($captcha,233,239,239); /* Now to make it a little bit harder for any bots to break, assuming they can break it so far. Lets add some lines in (static lines) to attempt to make the bots life a little harder */ imageline($captcha,0,0,39,29,$line); imageline($captcha,40,0,64,29,$line); /* Now for the all important writing of the randomly generated string to the image. */ imagestring($captcha, 5, 20, 10, $string, $black); /* Encrypt and store the key inside of a session */ $_SESSION['key'] = md5($string); /* Output the image */ header("Content-type: image/jpeg"); imagejpeg($captcha); ?> I don’t know where it all went wrong as I’m using pretty much the same code without problems here, here and here. The form isn't being used presently (apart from the spam) but I am itching to know what the problem is. P.S. The link to the CAPTCHA image wasn’t always http://echoing.org/captcha.php in the code. On the other forms and initially with this one the code was ./captcha.php but I changed it in case that was the problem. Looks like it isn’t. Thanks in advance!
  25. i want a situation where, when i upload something into my database, it creates a new table, everytime, i saw this $forum = "CREATE TABLE IF NOT EXISTS for_".$id." ( `id` int(11) NOT NULL AUTO_INCREMENT, `stud` int(11) DEFAULT NULL, `course` int(11) DEFAULT NULL, `message` varchar(1000) DEFAULT NULL, PRIMARY KEY (`id`) ) "; but don't know how to implement it into this query $sql = "INSERT into data(name,Groups,phone_number) values('$data[0]','$data[1]','$data[2]')";
×
×
  • 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.