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. Javascript timer not displaying correctly. It has always displayed properly , but today out of nowhere its just not working the hours and the minutes are not working but , the seconds are counting down. I am new to web development this is the CDN and the external ref to the countdown timer <script type="text/javascript" src= "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script> <script src="countdown.jquery.js"></script> <!-- this is countdown timer script" <!--> <script src="script.js"></script> <!-- this is where countdown timer is refences and where i change the date" <!--> below is the <script src="countdown.jquery.js"> (function($){ $.fn.countdown = function(options){ var settings={'date':null}; if(options){ $.extend(settings,options); } this_sel= $(this); function count_exec(){ eventDate=Date.parse( settings['date']) / 1000; currentDate= Math.floor($.now()/1000); seconds=eventDate -currentDate; days = Math.floor(seconds / (60 * 60 * 24)); seconds -= days * 60 * 60 * 24; hours = Math.floor(seconds / (60 * 60)); seconds -= hours * 60 * 60; minutes = Math.floor(seconds/60); seconds -= minutes * 60; this_sel.find('.days').text(days); this_sel.find('.hours').text(hours); this_sel.find('.mins').text(hours); this_sel.find('.secs').text(seconds); } count_exec(); interval=setInterval(count_exec,1000); } }) (jQuery); this is the jquery file <script src="script.js"></script> $(document).ready(function(){ $('#countdown').countdown({date: '26 January 2014 10:00:00'}); });
  2. Hi everyone. So I have a HTML form using PHP to pull a column from a MySQL table. However, I have a second field in my form that I want to pull a second row of data from that same table, when the first row is selected. Example DB Table: id=1 <---This is Primary Key name=ItemA <---This is the data that shows in the drop down list sku=1234 <---This is the data I want to throw into $_POST['sku'] when something is selected in name Here is the code I currently have for my form: <form method="POST" action="submitadd.php" /> <table id="add"> <tr> <td class="headings"><b>Species:</b></td> <td><select name=species:> <option value="select">Choose a Species</option> <?php $prodquery="SELECT name FROM products ORDER BY name ASC"; $result=mysqli_query($con,$prodquery) or die(mysqli_error($con)); while ($row = mysqli_fetch_array($result)) { echo "<option value='" . $row['name'] . "'>" . $row['name'] . "</option>"; } ?> </select> </td> </tr> <tr> <td class="headings"><b>SKU:</b></td> <td><input type="text" name="sku" value="<?php echo $row['sku']; ?>" readonly="readonly" size="35" /></td> </tr> Currently, the SKU field is a readonly field but I want it to pull data from the database when someone makes a select on the dropdown above. I assume this will require javascript? I have no experience with javascript, and was hoping someone could help me out or at least point me in the right direction. I don't have a clue how to search for this on Google. Thanks.
  3. I'm having a problem on how do I put primary keys whenever a user register another person. My pattern is this (batch number) + (incrementing value). For example a person named Cary register to my website and he inputted his batch number as batch 53, so his primary will become 53001. Then if another person named Josh with batch number 53 again register to my website his primary should be 53002. Then another person name Brock register but his batch is 36 so his primary should be 36001. So my solution is to get the batch number that the user inputted while they are registering then combine it with the incrementing value. My problem is how do I get the incrementing value and let the php know the next incrementing value? How do php know that the next number will be 003 or 004 or 005.
  4. Hello. I have a php form processor that I'm used to working with but I need someone to make some modifications for me. A. Right now, if a required field is missing, the processor tells the user that the field is required and asks them to press the "back" button and fill in that field. This works fine, however, if more than one required field is missing it only tells the user that one field at a time, so they have to keep hitting the back button for each missing field. If possible, I would like the processor to list ALL of the missing fields at one time. B. After the form is successfully submitted, it gives a generic "thank you" page and lets the user know they can close the window. I would like the form to redirect to a separate page so that I can modify the "thank you" page content for each form. I will send the code if you are interested. Thanks in advance for any help. I'm willing to trade this work for a graphic design, logo design, business cards, or free (legitimate) website hosting, otherwise let me know how much it will cost to have the processor modified.
  5. I have a MySQL query that is returning the results that I need correctly. However, I want to clean up the output a bit for my specific use case. Specifically, I'd like to remove a column from the output so that it only appears the first time it's pulled from the database. Here's a quick example of the type of output I'm getting: Campaign A - asset 1 Campaign A - asset 2 Campaign A - asset 3 Campaign B - asset 1 Campaign B - asset 3 Campaign C - asset 2 Campaign D - asset 1 Campaign D - asset 2 etc This is what I'd like instead: Campaign A asset 1 asset 2 asset 3 Campaign B asset 1 asset 3 Campaign C asset 2 Campaign D asset 1 asset 2 So, basically, I just want to see the "Campaign A" title once, even though it's part of the record of workshops. Here's the php code that I'm working with (in this case, "campaigntitle" is the column I only want to see once per group. "assettitle" would be shown in every row returned by the query) : <?php do { ?> <tr> <td><a href="detail-nd.php?recordID=<?php echo $row_assetslist['assetid']; ?>"> Details</a> <a href="assetupdate-nd.php?recordID=<?php echo $row_assetslist['assetid']; ?>">edit</a> delete</td> <td><?php echo $row_campaignassetjoin['campaigntitle']; ?></td> <td><?php echo $row_campaignassetjoin['assettitle']; ?></td> <td><?php echo $row_campaignassetjoin['assettype']; ?></td> </tr> <?php } while ($row_campaignassetjoin = mysql_fetch_assoc($campaignassetjoin)); ?> here's the pertinent mysql query in the document header: mysql_select_db($database_campaignarchive, $campaignarchive); $query_campaignassetjoin = "SELECT assets.*, campaign.* FROM campaign JOIN assets ON assets.campaignid=campaign.campaignid ORDER BY campaign.campaignid DESC"; $campaignassetjoin = mysql_query($query_campaignassetjoin, $campaignarchive) or die(mysql_error()); $row_campaignassetjoin = mysql_fetch_assoc($campaignassetjoin); $totalRows_campaignassetjoin = mysql_num_rows($campaignassetjoin);
  6. Hello I have a mysql database with filds like Name , DEPT ,and DOB the table name is emp and database name is EMPMASTER i have pear mail working script using gmail smtp and a Mysql query that shows todays birthday , My question is how to mix these two codes to mail output of that Mysql query in mail ? please suggest. following is the php code and my sql query. <?php // Pear Mail Library require_once "Mail.php"; $from = '<user@user.com>'; $to = '<user@user.com>'; $subject = 'Hi!'; $body = "Hi,\n\nHow are you?"; $headers = array( 'From' => $from, 'To' => $to, 'Subject' => $subject ); $smtp = Mail::factory('smtp', array( 'host' => 'ssl://smtp.gmail.com', 'port' => '465', 'auth' => true, 'username' => 'user@gmail.com', 'password' => '123@123' )); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo('<p>' . $mail->getMessage() . '</p>'); } else { echo('<p>Message successfully sent!</p>'); } ?> SELECT * FROM emp WHERE MONTH(dob) = MONTH(NOW()) AND DAY(dob) = DAY(NOW());
  7. Hi All I am Bruce, and am looking to build a strong PHP team, delivering web solutions in the Symfony 2.# framework. If anyone on here is interested in finding out more please message me. Best Regards Bruce
  8. Hi everyone. I'm working on a simple app for internal use for a small company. I am having difficulties getting the account logins working correctly, and I believe it has something to do with $_SESSION not being set like I expected it to. Now I am fairly new to PHP, and have been learning as I go. index.php contains this: <?php session_start(); require_once('includes/config.inc.php'); require_once('includes/functions.inc.php'); // Check login status -- if not logged in, redirect to login screen if (check_login_status() == false) { redirect('login.php'); } So when I load the app, I'm redirected to login.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-type" content="text/html;charset=utf-8" /> <title>Login Page</title> <link rel="stylesheet" type="text/css" href="css/login.css" /> </head> <body> <form id="login-form" method="post" action="includes/login.inc.php"> <fieldset> <legend>Login to Inventory System</legend> <p>Please enter your username and password to access the Inventory system</p> <label for="username"> <input type="text" name="username" id="username" />Username: </label> <label for="password"> <input type="password" name="password" id="password" />Password: </label> <label> <input type="submit" name="submit" id="submit" value="Login" /> </label> </fieldset> </form> </body> </html> When I hit submit on the login page, includes/login.inc.php is called: <?php session_start(); require_once('config.inc.php'); require_once('functions.inc.php'); // Escape any unsafe characters before querying database $username = $con->real_escape_string($_POST['username']); $password = $con->real_escape_string($_POST['password']); // Construct SQL statement for query & execute $query = "SELECT * FROM users WHERE username = '" . $username . "' AND password = '" . MD5($password) . "'"; $result = mysqli_query($con,$query) or die(mysqli_error($con)); // If one row is returned, username and password are valid if (is_object($result) && $result->num_rows == 1) { $_SESSION['logged_in'] = true; redirect('../index.php'); } else { redirect('../login.php'); } ?> Now I've been able to determine that the login is being processed successfully, because if I disable the check_login_status function in index.php, I'm redirected to index.php if I login with a valid account. Under the same conditions, an incorrect password will reload login.php. With the function disabled, I've also tried adding "print_r($_SESSION)" at the top of index.php, but nothing ever loads, which makes me think something is wrong with my function. functions.inc.php: <?php function redirect($page) { header('Location: ' . $page); exit(); } function check_login_status() { // IF $_SESSION['logged_in'] is set, return the status if (isset($_SESSION['logged_in'])) { return $_SESSION['logged_in']; } return false; } ?> config.inc.php: <?php $con=mysqli_connect("server_name","user","pass","db_name"); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } ?> I'm really at a loss, and I don't know where the problem is. I've checked for syntax errors with "php -l file.php" and found no syntax errors. I'm not sure how to do any other debugging with this, or what I'm missing. Help is truly appreciated! EDIT: Yes, I know MD5 passwords are not recommended, and that will be changed to use salt once I can get functionality in my app. I will also be escaping/preparing all MySQL queries once I get the login piece working.
  9. Hi I have an .m3u playlist file on my server, it has links to different songs on my server. The .m3u playlist streams all the music. The thing I want the .m3u file to do is shuffle the music instead of going in the same order. I've been using this method to do it but it doesn't work. Any other ways or something wrong with my code? <?php $playlist = “/DONTFUCKWITHME/playlist.m3u"; if ($_SERVER['PATH_INFO'] == "/playlist.m3u") { # This a request for the actual playlist. playlist(); } else { # Fall through to end of script and display # the player HTML. } function playlist() { header("Content-type: audio/mpeg"); # Needed for PHP versions OLDER than 4.2.0 only. # If your host still has PHP older than 4.2.0, shame on them. # Find a better web host. srand(make_seed()); # Fetch our list of songs from a file. $songs = file($playlist); shuffle($songs); # Now output the URLs in random order. foreach ($songs as $song) { # Remove newline and any other leading and trailing # whitespace from URL of song. $song = trim($song); echo "$song\n"; } # Now exit before any HTML is produced. exit(0); } # Needed only for very old versions of PHP, # see srand call earlier. function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } ?> <html> <head> <title>MP3s Playing in Random Order</title> </head> <body> <h1 align="center">MP3s Playing in Random Order</h1> <embed src="/examples/randomsongs.php/playlist.m3u" width="0" height="0" autostart="true" type="audio/mpeg" loop="true"/> </body> </html>
  10. Hi. I have made a application form for a job, I want the results the user enters into the boxes to come out into my database (evxhotel and the table apps). I get no errors and the website works perfectly fine but when I fill the form and submit the page just reloads and when I go to check my database I see that my results of the form are not in the database. I believe that maybe I put the mysql_connect and the mysql_select_db on the wrong lines. BTW, this is only the php script embedded into a html document. The file format and name is form.php. All the tags are correct. <?php $connect = mysql_connect("****", "****", "****") or die(mysql_error()); if(isset($_POST['submit'])){ $username = mysql_real_escape_string($_POST['Username']); $email = mysql_real_escape_string($_POST['Email']); $firstname = mysql_real_escape_string($_POST['First']); $lastname = mysql_real_escape_string($_POST['Last']); $day = mysql_real_escape_string($_POST['Day']); $month = mysql_real_escape_string($_POST['Month']); $year = mysql_real_escape_string($_POST['Year']); $time = mysql_real_escape_string($_POST['Time']); $position = mysql_real_escape_string($_POST['Position']); $why = mysql_real_escape_string($_POST['Why']); $what = mysql_real_escape_string($_POST['What']); $exp = mysql_real_escape_string($_POST['Exp']); $hours = mysql_real_escape_string($_POST['Hours']); $comments = mysql_real_escape_string($_POST['Comments']); mysql_select_db($connect, "evxhotel") or die(mysql_error()); $sql = mysql_query ("INSERT INTO apps (username, email, realname, dob, time, position, why, what, exp, hours, comments) VALUES ('".$username."', '".$email."', '".$firstname/$lastname."', '".$day/$month/$year."', '".$time."', '".$position."', '".$why."', '".$what."', '".$exp."', '".$hours.", '".$comments."')", $connect); if($sql) { echo "Your applicaton has been added to the database."; } else { die(mysql_error()); } } ?> Whats wrong? Thanks in advance.
  11. Hi Guys, I need to generate an AES file key (CBC/PKCS7/256bit) using PHP and then obviously need to store the key. The second phase is to encrypt a string using the key generated and stored above, however for the moment its the key generation that is the issue. My first thought was to use OpenSSL as it is a library that can be added to any Apache installation. Any help is greatly appreciated. Cheers in advance.
  12. hi there, i have the following query, which is supposed to return the valid sales lead counts and average the costs and count the leads during the past 30 days. SELECT SC.text_ServiceDescription, R.text_RegionDescription, GROUP_CONCAT(DISTINCT S.text_SupplierName SEPARATOR ', ') AS text_SupplierNames, IFNULL(SW.smallint_SuppliersWanted,0) AS bigint_SuppliersWantedAmount, COUNT(DISTINCT S.bigint_SupplierID) AS bigint_PremiumCustomersCount, ROUND(AVG(T.bigint_TransactionAmount),2) AS bigint_AvgCostPerLead, ROUND(COUNT(DISTINCT LS.bigint_LeadID, LS.smallint_LeadOrdinal),2) AS bigint_AvgNumLeadsGen FROM 4_servicesuppliers SS LEFT JOIN 2_servicescatalogue SC ON (SS.bigint_ServiceID = SC.bigint_ServiceID) LEFT JOIN 1_regions R ON (SS.bigint_RegionID = R.bigint_RegionID OR SS.bigint_RegionID = R.bigint_ParentRegionID) LEFT JOIN 5_suppliers S ON (SS.bigint_SupplierID = S.bigint_SupplierID) LEFT JOIN 11_supplierswanted SW ON (SS.bigint_ServiceID = SW.bigint_ServiceID AND R.bigint_RegionID = SW.bigint_RegionID) LEFT JOIN 3_serviceattributes SA0 ON (SC.bigint_PrimaryAttributeKey = SA0.bigint_AttributeID AND SC.bigint_ServiceID = SA0.bigint_AttributeServiceID) LEFT JOIN 3_serviceattributes SA1 ON (SA0.text_AttributeDescription = SA1.text_AttributeDescription AND SC.bigint_ServiceID = SA1.bigint_AttributeServiceID) LEFT JOIN 25_serviceleads SL ON (SC.bigint_ServiceID = SL.bigint_ServiceID AND SL.text_LeadAttributes LIKE CONCAT("%",SA1.text_AttributeDescription," = ",SA1.text_AttributeValue,"%")) LEFT JOIN 27_leadssent LS ON (SL.bigint_LeadID = LS.bigint_LeadID) LEFT JOIN 8_transactions T ON (SL.bigint_LeadID = T.bigint_LeadID AND LS.smallint_LeadOrdinal = T.smallint_LeadOrdinal) WHERE S.smallint_SupplierStatus = 0 AND IFNULL(SW.smallint_SuppliersWanted,0) > 0 AND SL.timestamp_LeadCreated >= DATE_SUB(CURDATE(),INTERVAL 30 DAY) AND SL.text_LeadAttributes LIKE CONCAT("%",SA1.text_AttributeDescription," = ",SA1.text_AttributeValue,"%") AND LS.text_Duplicates = "" GROUP BY SS.bigint_ServiceID, SW.bigint_RegionID ORDER BY SS.bigint_ServiceID ASC, R.bigint_RegionID ASC; however - this query takes forever to execute, even longer than the system timeout in phpmyadmin! also via php... in php i have a microtimer attached which times the query above, at 1568.6739211082 seconds. how can i optimize the query above, especially with regard to the 25_serviceleads, 27_leadssent and 8_transactions JOIN's? i have uploaded the sql digest for the tables above to this message, to recreate this issue (removing the email addresses of course - as we do not condone spam ) to: http://performatix.co/Untapped_Potential_Income.zip please respond if you authentically know your mysql (especially the joins!) - you are welcome to assist. i have not been able to do the course myself yet - what i do know - is all as result of a lifelong hobby. sincerely, Pierre "Greywacke" du Toit.
  13. One of the sites I manage is trending towards 40% mobile and tablet visitor. Remodeled and greatly expanded the mobile section and am looking for feedback on appearance in mobile/tablet devices. http://vvaarizona.org/mobile/index.html Thanks, Aaron
  14. Hi Hoping for some help after resolving other errors/warnings and spending abit on one issue and havent figured it out. I was hoping for some help here. Thanks for any help. Error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/91/12175191/html/php/file.php on line 16 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0, 1' at line 1 <?php function outputGrumbles($grumble, $home = false) { global $conn; if($grumble) { setTimezone(); $sql = "SELECT cg.category_name, cg.category_url, scg.sub_category_id, scg.sub_category_name, scg.sub_category_description, scg.sub_category_url, " . "(COUNT(DISTINCT sg.status_id) + COUNT(DISTINCT ulg.user_like_id)) AS grumble_number, " . "DATE_FORMAT(scg.sub_category_created, '%b %e, %Y %l:%i %p') AS sub_category_created " . " FROM sub_category_grumble AS scg " . "LEFT OUTER JOIN categories_grumble AS cg ON cg.category_id = scg.category_id " . "LEFT OUTER JOIN status_grumble AS sg ON sg.sub_category_id = scg.sub_category_id " . "LEFT OUTER JOIN user_likes_grumble AS ulg ON ulg.sub_category_id = scg.sub_category_id " . "WHERE scg.sub_category_id = " . $grumble . "LIMIT 0, 1"; $result = mysql_query($sql, $conn); if($row = mysql_fetch_array($result)) { echo '<div class="grumble-holder">'; echo '<div class="'; if($home) { echo 'content-padding-home'; } else { echo 'content-padding'; } echo '">'; echo '<div class="grumble-comment-number">'; if($home) echo '<p><a href="/category/' . $row["category_url"] . '" class="colored-link-1 grumble-cat-name" title="' . $row["category_name"] . '">' . $row["category_name"] . '</a></p>'; echo '<p class="grumble-comment-font" title="' . $row["grumble_number"] . ' comments/votes on this Grumble">'; echo $row["grumble_number"]; echo '</p>'; echo '</div>'; echo '<div class="grumble-text-holder">'; echo '<h3><a href="/' . ($row["category_url"]) . '/' . $row["sub_category_url"] . '/' . $row["sub_category_id"] . '" data-id="' . $row["sub_category_id"] . '" class="colored-link-1">' . stripslashes($row["sub_category_name"]) . '</a></h3>'; echo '<p class="grumble-description">' . stripslashes($row["sub_category_description"]) . '</p>'; echo '</div>'; echo '</div>'; echo '</div>'; } if (false === $result) { echo mysql_error(); } } } ?> Again thank you for any help.
  15. I'm trying to test error conditions for file uploads, but when a file intentionally fails, I'm not even sure how to access the code. Here's a snippet: $file_arr = $_FILES[ 'digifile' ]; $fn = $file_arr[ 'name' ]; $temp = $file_arr[ 'tmp_name' ]; $error = $file_arr[ 'error' ]; error_log( 'the error is: ' . $error ); // ** SEE NOTE BELOW if ( $error > 0 ) { $ui->upload_message = "Error during file upload. "; // try to switch the error to show a relevant message } else { if ( move_uploaded_file( $temp, $full_path ) ) // something } My test for now is simple... test a small image file, it's fine. But I have set my max file size to 16MB in php.ini, and I'm intentionally uploading a 19MB file. What is the expected result? Well I can tell you that the result is this code IS NOT REACHED AT ALL! How is that possible? error_log() doesn't get reached. I don't really know what happens when there is an error, but I'd like to show a customer a relevant message if this happened in the real world. There's no boolean result of move_uploaded_file, either, since like I said THE CODE ISN'T REACHED. I really don't understand. Any help is appreciated.
  16. I have a website that i integrate a chat app into it (FREICHAT ) now i wanted to make the user that log in to my the site to chat with user name, according to freichat this idea is 100% possible and they have solution for it. I have done all the want me to do but it is not working, so i came meet my gurus to please help me out below are my code. <?php $ses = null; // Return null if user is not logged in if(isset($_SESSION['username'])) { if($_SESSION['username'] != null) // Here null is guest { $ses=$_SESSION['username']; //LOOK, now userid will be passed to FreiChat } } if(!function_exists("FreiChatx_get_hash")) { function FreiChatx_get_hash($ses){//And the rest of the code as it is . . if(is_file("C:/wamp/www/Dagogo_temp/freichat/hardcode.php")){ require "C:/wamp/www/Dagogo_temp/freichat/hardcode.php"; $temp_id = $ses . $uid; return md5($temp_id); } else { echo "<script>alert('module freichatx says: hardcode.php file not found!');</script>"; } return 0; } } ?> <script type="text/javascript" language="javascipt"src="http://localhost/Dagogo_temp/freichat/client/main.php?id=<?php echo $ses;?>&xhash=<?php echo freichatx_get_hash($ses); ?>"></script> <link rel="stylesheet" href="http://localhost/Dagogo_temp/freichat/client/jquery/freichat_themes/freichatcss.php" type="text/css"> <!--===========================FreiChatX=======END=========================--> the next file i change is the hardcore.php <?php /* Data base details */ $con = 'mysql'; // MySQL , Oracle , SQLite , PostgreSQL $username='root'; // Database username $password=''; //Database password $client_db_name='online'; //Database name $host='localhost'; //host $port=''; //optional port for some servers using different port $driver='Custom'; //Integration driver $db_prefix=''; //prefix used for tables in database $uid='52b2c4244f15f'; //Any random unique number $PATH = 'freichat/'; // Use this only if you have placed the freichat folder somewhere else $installed=true; //make it false if you want to reinstall freichat $admin_pswd='adminpass'; //backend password $debug = false; /* email plugin */ $smtp_username = ''; $smtp_password = ''; /* Custom driver */ $usertable='users'; //specifies the name of the table in which your user information is stored. $row_username='username'; //specifies the name of the field in which the user's name/display name is stored. $row_userid='id'; //specifies the name of the field in which the user's id is stored (usually id or userid) $avatar_field_name = 'avatar'; Please help me out
  17. hello? I hope to get some help, I have a script of job applications, basically what it does is when a user is going to apply for a job, the user information (name, email, message, cv) are sent to the database and the CV is saved in a folder on the server.The company that created the job opening receives an email with the details of the candidate that was filled in the form. The script works fine, but I have only one problem, I need to get in the email the CV attached but i dont no how to do. Could someone see the code and tell me what is missing in add code and how to fill the rest? Here is the code above if(isset($_FILES['files'])){ $errors= array(); foreach($_FILES['files']['tmp_name'] as $key => $tmp_name ){ $file_name = $key.$_FILES['files']['name'][$key]; $file_size =$_FILES['files']['size'][$key]; $file_tmp =$_FILES['files']['tmp_name'][$key]; $file_type=$_FILES['files']['type'][$key]; $random_digit=rand(0000,9999); $new_file_name=$random_digit.$file_name; if($file_size > 2097152){ $errors[]='File size must be less than 2 MB'; } $query2="INSERT into candidates (`firstname`,`lastname`,`mobile`,`email`,`message`,`id_company`,`titulo_anuncio`,`job_type`,`data`,ativo) VALUES('$firstname','$lastname','$mobile','$email_candidate','$message','$id_company','$title_en','$job_type','$data','1'); "; mysql_query($query2); $user_id = mysql_insert_id(); $query="INSERT into imagens (`id_candidate`,`file`,`size`,`type`) VALUES('$user_id','$new_file_name','$file_size','$file_type'); "; $to = $email; $subject = " Job Portal - New Candidate"; $body = ""; $body .= "Title: "; $body .= $title_en; $body .= "\n"; $body .= "Tel: "; $body .= $mobile; $body .= "\n"; $body .= "Email: "; $body .= $email_candidate; $body .= "\n"; $body .= "Message: "; $body .= $message; $body .= "\n"; $body .= "CV: "; $body .= "In attachement"; $body .= "\n"; $headers = "From:" . $to; if (mail($to, $subject, $body,$headers)) $desired_dir="candidatos_cv"; if(empty($errors)==true){ if(is_dir($desired_dir)==false){ mkdir("$desired_dir", 0700); } if(is_dir("$desired_dir/".$new_file_name)==false){ move_uploaded_file($file_tmp,"$desired_dir/".$new_file_name); }else{ // rename the file if another one exist $new_dir="$desired_dir/".$new_file_name.time(); rename($file_tmp,$new_dir) ; } mysql_query($query); }else{ print_r($errors); } } if(empty($error)){ echo "<span style=\"color:green;font-weight:bold;\">Job applied whit Sucess</span>"; } }
  18. I'm not really sure were this belongs because I don't really know which part of my script is causing the problem. So I have screen printed my issue. I think screen printing and showing you guys what my problems are is a great idea rather then me trying to explain myself. Pictures show more than words. But anyways. My main problem is that I want to insert the data "privacy=everyone" into it's own separate column, but also take the "privacy" out and insert into the column with the data "everyone". This is what I got so far. This is my issue I have on a live page. I cropped everything out except the issue. Here is my PHP code. Here is my Jquery code. And here is my MySQL data. My ideal MySQL data would look something like this. If I forgot something, I'll edit this post. EDIT: I should also mention that some of the PHP codes are whiten out in case of coping. The status and category are suppose to be one, but I had whiten out the other codes so the category and status looks like they're not aligned, but they are in my real code.
  19. I am having a problem understanding why when I run my script and I put the results inside a select statement it does not show the values but when I remove the select statement the values or visible . The following code will show you what I mean. If you comment out the select statement in the html script it will work. I don't understand way <?php // CONNECT TO THE DATABASE $DB_NAME = 'notary'; $DB_HOST = 'localhost'; $DB_USER = 'root'; $DB_PASS = ''; $db=$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } ?> <?php include("db.php"); $sql='SELECT * FROM customer'; $result=$db->query($sql); while($row = mysqli_fetch_array($result,MYSQLI_BOTH)) { echo "<option value=" . $row['name'] . ">" .$row['name'] . "</option>"; } <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>ready demo</title> <script src="js/jquery.js"></script> <script> $( document ).ready(function() { $.ajax({ //create an ajax request to load_page.php type: "GET", url: "php/display.php", dataType: "text", //expect html to be returned success: function(response){ $("#responsetext").text(response); //alert(response); } }); /*$( "p" ).text( "The DOM is now loaded and can be manipulated." );*/ }); </script> </head> <body> <div align="center"> <select name="customer"> <!--<---comment out this line--> <div id="responsetext"> </select> <!--<---comment out this line--> </div> </body> </html>
  20. I have a script to upload image to a folder and store image name in the database but there seems to be something wrong with my scripting and me please some one help me out. <?php //start a session for error reporting. session_start(); //call our connection file. require("include/conn.php"); // check to see if the type of file uploaded is valid image type. function is_valid_type($file) { //This is an array that holds the valid image MIME Types $valid_types=array("image/jpg","image/gif","image/png","image/swf","image/jpeg","image/x-ms-bmp","image/x-png"); if (in_array($file["type"],$valid_types)) return 1; return 0; } //just a short function that print out the content of an array in mannerthat is easy to read // set some constants //this variable is the part to the image folder where all the images are going to be stored //Note that there is trailing forward slash $target_path="upload_images/"; //Get our Posted variables $name=$_POST["name"]; $phone=$_POST["phone"]; $address=$_POST["address"]; $email=$_POST["email"]; $username=$_POST["username"]; $password=$_POST["password"]; $pin=$_POST["pin"]; $family=$_POST["family"]; $image=$_FILES["image"]; //***sanitizing our inputs // $name=mysql_real_escape_string($name); $name=stripslashes($name); // end sanitizing name input $phone=mysql_real_escape_string($phone); $phone=stripslashes($phone); // end sanitizing phone input $address=mysql_real_escape_string($address); $address=stripslashes($address); // end sanitizing address input $email=mysql_real_escape_string($email); $email=stripslashes($email); // end sanitizing $email input $username=mysql_real_escape_string($username); $username=stripslashes($username); // end sanitizing username input $password=mysql_real_escape_string($password); $password=stripslashes($password); // end sanitizing password input $pin=mysql_real_escape_string($pin); $pin=stripslashes($pin); // end sanitizing pin input $family=mysql_real_escape_string($family); $family=stripslashes($family); // end sanitizing family input $image['name']=mysql_real_escape_string($image['name']); $image['name']=stripslashes($image['name']); // end sanitizing image name input //Build our target path full string. this is where the filewill be moved to. $target_path.=$image['name']; // make sure all the fields are entered if (empty($name)||empty($phone)||empty($address)||empty($email)||empty($username)||empty($password)||empty($pin)||empty($family)||empty($image["name"])) { $_SESSION["error"]="All Fields Are Required"; header("location:register.php"); exit; } //check to make sure that our file is actually an image //we check the file type instead of the extension because the extension can easily be faked. if(is_valid_type($image)==False) { $_SESSION["error"]="You Must Upload a Jpeg,gif,png,swf or jpg image file "; header("location:register.php"); exit; } // here we check to see if a file with that name already exists and we rename it //we just rename all file $rand=rand(0,9999999999); $new_image=$rand.$image["name"]; if(file_exists($target_path)) {$_SESSION["error"]="Please Rename Your Image And Try Again "; header("location:register.php"); exit; } // attempting to move the file from its temporary directory to its new home if(move_uploaded_file($new_image["tmp_name"],$target_path)) { // we are putting a reference to the file in the database. $sql=mysql_query("INSERT INTO facilitators(name,phone,address,email,username,password,pin,family,image)VALUE('$name','$phone','$address','$email','$username','$password','$pin','$family','"$new_image['name']."')")or die("Could Not Insert into the Data Base:".mysql_error()); header("location:index.php"); exit; } else { {$_SESSION["error"]="Could Not Register You Please contact Web Master on 08132841856 "; header("location:register.php"); } ?> It display a prase error on 114 Parse error: parse error in C:\wamp\www\Teens Site\check.php on line 114 and this line 114 $sql=mysql_query("INSERT INTO facilitators(name,phone,address,email,username,password,pin,family,image)VALUE('$name','$phone','$address','$email','$username','$password','$pin','$family','"$new_image['name']."')")or die("Could Not Insert into the Data Base:".mysql_error()); Thanks a lot for all the assistance i have been receiving.
  21. i designed a form with a php send via email. what i cant figure out is how to collect the info from the checkboxes and put in the php this is the check box: <td id="td_element_field_0" style=""><div style="width:100%;padding-bottom:5px;"><input id="element_0_0" name="element_0[]" value="Health" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000"> Health </font></div><div style="width:100%;padding-bottom:5px;"><input id="element_0_1" name="element_0[]" value="Finances" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000"> Finances </font></div><div style="width:100%;padding-bottom:5px;"><input id="element_0_2" name="element_0[]" value="Family" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000"> Family </font></div><div style="width:100%;padding-bottom:5px;"><input id="element_0_3" name="element_0[]" value="Personal Dreams, Goals & Visions" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000"> Personal Dreams,Goals & Visions </font></div><div style="width:100%;padding-bottom:5px;"><input id="element_0_4" name="element_0[]" value="Restoration" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000"> Restoration </font></div><div style="width:100%;padding-bottom:5px;"><input id="element_0_5" name="element_0[]" value="Special Unspoken Request" class="validate[required]" type="checkbox" /><font face="Verdana" size="2" color="#000000"> Special Unspoken Request </font></div><div style="clear:both;"></div><div style="padding-bottom:8px;color:#000000;"><small><font face="Verdana"></font></small></div> this is the php <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "support@higherpowercomputers.com"; $email_subject = "Prayer Request or Praise Report"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['prayer_praise'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $prayer_praise = $_POST['prayer_praise']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($prayer_praise) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Phone Number: ".clean_string($phone_number)."\n"; $email_message .= "Email: ".clean_string($email)."\n"; $email_message .= "Subject: ".clean_string($subject)."\n"; $email_message .= "Prayer and or Praise Report: ".clean_string($prayer_praise)."\n"; // create email headers $headers = 'From: '.$email."\r\n". 'Reply-To: '.$email."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> echo "<script>window.location = 'http://www.higherpowercomputers.com/faith//thank_you.html'</script>"; <?php } ?>
  22. ERROR: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/m4st3r/public_html/inbox.php on line 34 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/m4st3r/public_html/inbox.php on line 35 CODE: $num = mysql_num_rows($allusers = mysql_query("SELECT * FROM PMs WHERE `status`='0' AND ReceiveID='$myU->ID' ORDER BY ID")); $PMs = mysql_num_rows($allusers = mysql_query("SELECT * FROM PMs WHERE `status`='0' AND `LookMessage`='0' AND ReceiveID='$myU->ID' ORDER BY ID")); PIC:
  23. Hello. I've gotten my self really confused with server end checks for users being logged in. I create a session in PHP by using a straight forward ajax request and check the database against the user & pass sent to the server. I then set a session like this: $_SESSION['uid'] = $row['uid']; But i want to check this session in NodeJS aswell so i don't have to keep validating the user when they send data on a socket. The script i have is like this: socket.on('sendMessage', function(data,callBack){ var userID = //assign $_SESSION['uid'], possible? if(!userID){ console.log('User not logged in!'); } else { var message = sanitize(data['message']).escape(); var query = connection.query('SELECT name FROM users WHERE uid = ?', [userID], function(err,results){ if(err){ console.log('Query Error: '+err); } else if(results.length == 1){ var username = results[0].name; console.log(username+' sent a message!'); } }); }); How do i use the session in this situation - i can't work out how to do it =/ Please help, really confused!
  24. OK i am very new to PHP so please be gentle LOL. I am posting a form to Liveaddress API and then i get the response back in an array it looks like this Array ( [0] => Array ( [input_index] => 0 [candidate_index] => 0 [delivery_line_1] => 13700 Oakland St [last_line] => Highland Park MI 48203-3173 [delivery_point_barcode] => 482033173009 [components] => Array ( [primary_number] => 13700 [street_name] => Oakland [street_suffix] => St [city_name] => Highland Park [state_abbreviation] => MI [zipcode] => 48203 [plus4_code] => 3173 [delivery_point] => 00 [delivery_point_check_digit] => 9 ) [metadata] => Array ( [record_type] => S [zip_type] => Standard [county_fips] => 26163 [county_name] => Wayne [carrier_route] => C021 [congressional_district] => 14 [rdi] => Commercial [elot_sequence] => 0024 [elot_sort] => A [latitude] => 42.40858 [longitude] => -83.08783 [precision] => Zip9 ) [analysis] => Array ( [dpv_match_code] => Y [dpv_footnotes] => AABB [dpv_cmra] => N [dpv_vacant] => N [active] => Y [footnotes] => L# ) ) ) How would i take primary_number and turn that into a variable to then insert into a database? Thanks, T
  25. Heey, Could some one help me to make like 5 / 10 sum generator with random codes and each sum on a other page? Maybe you got skype and you could help me out and help me? So I got teached also I was thinking about to make a IF - statement to make a If page <= then page 10 he will make random sums and at the end show the result? But I don't know how I need to make that. got this page so far: <?php SESSION_START(); if(!empty($_POST['submit'])) { $pre=$_SESSION['ans'']; $answer=$_POST['ant']; $1= rand(0,30); $2= rand(0,30); $answer=$1+$2; $_SESSION['ans']=$answer; echo "<br>$1+$2="; } else { ?> <html> <head> <title>Math</title> </head> <body> <h2>+</h2> <form method='post' action=''> Your answer:<input name='ans'><br> </select> <br><br> <input name='submit' type='submit' value='next'> <input name='reset' type='reset' value='delete'> </form> <?php } ?> Thank you~
×
×
  • 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.