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. Hello guys! For every word in a sentence or phrase how do i make the first letter for each word a capital letter. Expecting your response Thanks guys!
  2. Hi guys, i am creating my change password site for my website and i have some problems with the code... For some reason i have difficulties with the passwords being compared and replaced in the db after crypting them. I wanted this: Either get the current users password and compare it to the input value of $oldpass or compare the input value of $oldpass with the password stored in the database for the current user. After checking if the $oldpass and the password from the database match and IF they match then take the input value of $newpass and $repeatpass, compare them and if they match, then crypt() $newpass and update the database with the new password. I am not even sure if the passwords are even crypted. Also in the code i am comparing $oldpass with $_SESSION['password'] which is not the password from the db, i can't figure out how to call the password from the db. Thanks in advance! <?php include 'check_login_status.php'; $u=""; $oldpass=md5($_POST['oldpass']); //stripping both strings of white spaces $newpass = preg_replace('#[^a-z0-9]#i', '', $_POST['newpass']); $repeatpass = preg_replace('#[^a-z0-9]#i', '', $_POST['repeatpass']); //get the username from the header if(isset($_GET["u"])){ $u = preg_replace('#[^a-z0-9]#i', '', $_GET['u']); } else { header("location: compare_pass.php?u=".$_SESSION["username"]); exit(); } // Select the member from the users table $sql = "SELECT password FROM users WHERE username='$u' LIMIT 1"; mysqli_query($db_conx, $sql); $user_query = mysqli_query($db_conx, $sql); // Now make sure that user exists in the table $numrows = mysqli_num_rows($user_query); if($numrows < 1){ echo "That user does not exist or is not yet activated, press back"; exit(); } if ($oldpass == $_SESSION['password']) { echo "session and oldpass are matching"; } else { echo "Session and oldpass do not match!"; } $isOwner = "no"; //check if user is logged in owner of account if($u == $log_username && $user_ok == true){ $isOwner = "yes"; } $passhash = ""; if (isset($_POST["submit"]) && ($isOwner == "yes") && ($user_ok == true) && ($newpass == $repeatpass)) { $passhash = crypt_sha256("$newpass", "B-Pz=0%5mI~SAOcW0pMUdgKQh1_B7H6sbKAl+9~O98E9MBPrpGOtE65ro~8R"); $sql = "UPDATE users SET `password`='$passhash' WHERE username='$u' LIMIT 1"; } if (mysqli_query($db_conx, $sql)) { echo "Record updated successfully"; } else { echo "Error updating record: " . mysqli_error($db_conx); } ?> <h3>Create new password</h3> <form action="" method="post"> <div>Current Password</div> <input type="text" class="form-control" id="password" name="oldpass" > <div>New Password</div> <input type="text" class="form-control" id="password" name="newpass" > <div>Repeat Password</div> <input type="text" class="form-control" id="password" name="repeatpass" > <br /><br /> <input type="submit" name="submit" value="Submit"> <p id="status" ></p> </form><?php echo "{$oldpass}, {$_SESSION['password']}"; ?> <pre> <?php var_dump($_SESSION); var_dump($oldpass); var_dump($passhash); var_dump($newpass); var_dump($repeatpass); ?> </pre>
  3. else if (preg_match('BSD',$ua) || preg_match('FreeBSD',$ua) || preg_match('NetBSD',$ua)) { $browser['platform'] = "BSD"; Warning: preg_match(): Delimiter must not be alphanumeric or backslash in /Homepages/33/d183561635/htdocs/xtc.../includes/pt_counter.stats.php on line 76 Can anybody help for the correct code?
  4. Please Help me to solve my problem.. I'm having some difficulties in solving the issue please HELP me I have this code <div class="span5"> <?php $get_id = $_GET['org_id']; $oid = isset($_GET['org_id'])?$_GET['org_id']:""; $query_vote=mysql_query("select * from votes where position='President' and voters_id='$session_id'"); $count=mysql_num_rows($query_vote); $row=mysql_fetch_array($query_vote); $id=$row['vote_id']; if ($count==1){ ?> <script type="text/javascript"> jQuery(document).ready(function() { $('#delete<?php echo $id; ?>').tooltip('show'); $('#delete<?php echo $id; ?>').tooltip('hide'); }) </script> <h6>My Candidate for President</h6> <div class="none"><img class="img-polaroid" src="admin/<?php echo $row['img']; ?>" width="88" height="88"/> <a><?php echo $row['firstname']." ".$row['lastname']; ?></a> <a class="btn btn-danger" data-placement="right" id="delete<?php echo $id; ?>" title="Click to Remove" href="#<?php echo $id; ?>" data-toggle="modal"> <i class="icon-remove icon-large"> </i></a> <!---delete modal --> <?php include('delete_user_modal.php'); ?> <!---delete modal --> <?php }else{ ?> <h6>Candidate for President</h6> <?php $result = mysql_query("SELECT candidates.candidates_id, candidates.firstname, candidates.lastname, candidates.img FROM candidates INNER JOIN voters ON voters.org_id = candidates.org_id WHERE position='President' AND candidates_id='$get_id' "); while($row=mysql_fetch_assoc($result)) { $id=$row['candidates_id']; ?> <script type="text/javascript"> jQuery(document).ready(function() { $('#a<?php echo $id; ?>').tooltip('show'); $('#a<?php echo $id; ?>').tooltip('hide'); }) </script> <div class="picture"><img data-placement="bottom" id="a<?php echo $id; ?>" title="Drag the Image to the ballot Box to Vote for <?php echo $row['firstname']." ".$row['lastname']; ?>" class="img-polaroid" src="admin/<?php echo $row['img']; ?>" width="88" height="128"/> <br> <a><?php echo $row['firstname']." ".$row['lastname']; ?></a> </div> <?php } ?> <?php } ?> <div> But the problem is that im getting this error in my page Notice: Undefined index: org_id please help me and give me some advice on how to resolve this
  5. It is hard to explain the situation.. Better have a look at the attatchment.. run the sccript and add some mp3 file in music folder. now browse the script and you will find something like this Why the metadata only added in first file? Something Helpful: * id.php is used to extract metadata like Album, Artist etc. * Line 168-177 is the loop for mp3 file. * I on't nee to show metadata in download page. I only want to show metadata of every file on the loop.
  6. Good Day, Please help me to create a simple organisation management in php so this is the scenario, i have 3 tables (organisation, student, teacher) the simple system works fine But the problem is that adding organisation to my system. ? because before i just type it in my query WHERE org_name = 'COMTECH' to my students query and to my index query after i log in as a student how can i add organisation and create a log in that connects the student on the organisation that he is registered ? So this the example data in my database table Organisation.tbl org_id: 1 org_name: COMTECH org_description: computer fundamentals Student.tbl Teacher.tbl student_id: 1 teacher_id: 1 username: student username: teacher password: demo password: demo firstname: alvin user_type: Admin lastname: biares So right no im having hard time to solve the problem that if the organisation was created and the students are registered to that organisation the student can see only the teachers who are already registered in that organisation. ? please help me..
  7. hello dear php-experts, the question of the day - how to find a file with a certain text - the commands below do not help here .... the are good but they do not open the file find . | xargs grep "texthere" * grep -r "texthere" . grep -r "a target="_blank"" find ./ -type f | xargs grep "foo" hmm - well i guess that the grep command will help here. well i want to do a seach recursively - through all files in a folder. And i want to open fhe file - after it is found. How can we do this!? love to hear from you
  8. Hi, I have a PHP script sendEmail.php that given some data (receiver, content, etc), sends an email to the receiver. When i click the Send button i fire the sendEmail.php script using AJAX: $('#sendbutton').on('click', function(){ $.ajax({ type: "POST", url: "js/ajax/sendEmail.php", data: {receiver:receiver, content: content} }); }); I want to add a feature call "Schedule send" where the user can select in how many minutes the email will be send. What i did, was to take the minutes value, insert it into a countDown timer, and as soon as the time is Zero, to fire the same AJAX call. This is working only if the browser is open. And i can understand this, since it is Javascript's responsibility to fire the AJAX call since its the one on client site. QUESTION: Is there a way to fire this sendEmail.php scipt even if the web browser is closed?Using PHP/MYSQL of course.. For example the user will select the recipient, write the email, schedule it to be sent 20 minutes later, and close the browser. If not, what are your suggestions? Thanks in advance, Christos
  9. I am trying to create a dynamic form using Jquery but don't know how to post those data using $_POST. The page <html> <head> <title> Dynamically create input fields- jQuery </title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript"> $(function() { var addDiv = $('#addinput'); var i = $('#addinput p').size() + 1; $('#addNew').live('click', function() { $('<p><input type="text" id="p_new" size="40" name="p_new_' + i +'" value="" placeholder="I am New" /><input type="text" id="p_new2" size="40" name="p_new_2' + i +'" value="" placeholder="I am New 2" /><a href="#" id="remNew">Remove</a> </p>').appendTo(addDiv); i++; return false; }); $('#remNew').live('click', function() { if( i > 2 ) { $(this).parents('p').remove(); i--; } return false; }); }); </script> </head> <body> <h2>Dynammically Add Another Input Box</h2> <form action="gen.php" method="post"> <div id="addinput"> <p> <input type="text" id="p_new" size="40" name="p_new" value="" placeholder="Input Value" /><input type="text" id="p_new2" size="40" name="p_new2" value="" placeholder="Input Value" /><a href="#" id="addNew">Add</a> </p> </div> </form> </body> </html> Here is live example.. A Pen by Captain Anonymous Whatever, The new fields got an unique name="" value as p_new_1, p_new_21 for first new field, p_new_2, p_new_22 for second new field ...... ...... Now, I know I can display inserted data using <?php echo $_POST["p_new_1"]; ?> and similar way like this... But as a growing field, this form can have unlimited input field. How can I display all of those data in the page gen.php? It must be something like this example: <html> <body> <div class="header">Generated content<div> <p><a href="inserted data of first field of default row">inserted data of second field of default row</a></p> <p><a href="inserted data of first field of first new row">inserted data of second field of first new row</a></p> <p><a href="inserted data of first field of 2nd new row">inserted data of second field of 2nd new row</a></p> <p><a href="inserted data of first field of 3rd new row">inserted data of second field of 3rd new row</a></p> <p><a href="inserted data of first field of 4th new row">inserted data of second field of 4th new row</a></p> And list go on according to submitted form.... </div></body></html> I actually lake of knowledge of PHP and no idea about array or something named loop. Can someone do it for me? What I have to do in gen.php?
  10. Hello guys! I really really really hope anyone can help me because I am quite desperate about a little project I'm making. I want to construct a sort of online catalog for books with a "shoppingcart" and a profile for every user, but object orientated. I have a database with the table products which contains: ID, title, author, genre, price etc etc etc My main question is: How can I get one single field from the database with e.g. a function called getPrice(); I tried everything but nothing displays the data the way i want to. I simply want to have a sql-statement in this function and when I am calling the function getPrice() later on it displays just the number and no Array, code or whatever. Is there a way to call getPrice() and get "20.00" back? Please Help!
  11. I am creating a word scramble game in PHP .But I am having difficulty in doing it. What Iam planning to do is to get the jumbled words from the database and display it as tile format or individual buttons . The words are scrambled and I have to do dragging it so that it matched the word from mysql. First how to get individual letters from mysql and that too scrambled. Individual letters , I know it is str_split($words) so that the letter is split into letters. Please help me on this.
  12. Hello I am a desktop / database programmer. I wish to write a program to read data from a database and populate a combobox in an html page. I have read that PHP can do this. Is this correct? I would prefer not to have to use a web server since this is a local app and there will be one page and it will be static excpet for a few selection criteria (like a combobox). All the examples I see are for web pages. If this can be done can someone point me in the right direction? Thanks JM
  13. Hello, So I need to convert PHP code to JSP/Java. I really don't understand PHP and would like an explanation as to what this code is doing. So I can convert it, any help would be great thank you it's only 4 lines of code sitemap.php Attached PHP file
  14. Hi; I'm writing a php script which is about advertising.I created a table and i wanted to get informations from the column which is in the table , is named "tema".For example ; i created a table which is called "ilan" ; and in the table i created a column which is named "tema" i got the information from the MYSQL "tema='tehnika'" everything is allright till this moment after this when i opened my php file i couldnt see the ROW which is "tema='tehnika'" in the index although i got to one row .. When i look the sources of my index i see that PHP got allrows and also when i search the browser other rows browser can find but it doesnt show where these words are located :S first i think maybe something wrong with my CSS properties. but it is not about CSS so where is the wrong ? ???? This is my source codes: <?php require_once('baglan.php');//i connected to Database// if($db->connect_errno) die("Veritabanına bağlanılamıyor.".$db->connect_error()); $db->set_charset("utf-8"); $toplam=$db->prepare("SELECT count(*) FROM ilanlar WHERE tema='tehnika'"); $toplam->execute(); $sayfa_sayisi=$toplam->get_result(); $sayfacik=$sayfa_sayisi->fetch_row(); $toplam->close(); $sql=$db->prepare("SELECT * FROM ilanlar WHERE tema='tehnika' Order By id DESC LIMIT ? OFFSET ?"); $limit=4; $offset=isset($_GET["id"]) ? $_GET["id"] : 0 ; $sql->bind_param("ii",$limit,$offset); $sql->execute(); $sql_sonuc=$sql->get_result(); while($row=$sql_sonuc->fetch_array()) { echo "<div id='ilanlar'> <h1><img src='yuklemeler/{$row["fotoadi"]}'><a href=detay.php?id={$row["id"]}>{$row["konu"]}</a></h1> <p><h3>{$row["tarih"]}</h3></p> <br/></div> "; } if($sayfacik[0]>$limit) { $x = 0 ; for($i = 0 ; $i<$sayfacik[0];$i+=$limit) { $x++; } } $db->close(); ?> http://i57.tinypic.com/2ccow9x.png
  15. So this is the scenario, i have 3 tables in my database voters.tbl, candidates.tbl, organisation.tbl so if the voters registered by the organisation and the candidates registered in the same organisation like the voters. The user/Voters must see only the candidates that has the same id of a voter. Let's say ORGANISATION.TBL ---------------------- CANDIDATES.TBL org_id: 1 ------------------- org_name: umbrella candidates_id: 1 firstname: ramon lastname: mclights org_id: 1 VOTERS.TBL ------------------ voters_id: 1 firsname: Anne lastname: Sunga org_id: 1 The bold text are the value of the column Please help me here how can i Query and compares the id of candidates and voters
  16. I am brand new to php and MySQL. I am working on a small project and I am getting this error and I cannot find the reason why. Can someone please help. The error is Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in C:\xampp\htdocs\test\records.php on line 134 <?php /* Allows the user to both create new records and edit existing records */ // connect to the database include("connect-db.php"); // creates the new/edit record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($first = '', $middle = '', $last = '', $ClientID = '', $Diagnosis = '', $Gender = '', $LevelCare = '', $Counselor = '', $error = '', $id = '') { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title> <?php if ($id != '') { echo "Edit Record"; } else { echo "New Record"; } ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> </head> <body> <h1><?php if ($id != '') { echo "Edit Record"; } else { echo "New Record"; } ?></h1> <?php if ($error != '') { echo "<div style='padding:4px; border:1px solid red; color:red'>" . $error . "</div>"; } ?> <form action="" method="post"> <div> <?php if ($id != '') { ?> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <p>id: <?php echo $id; ?></p> <?php } ?> <strong>First Name: *</strong> <input type="text" name="FirstName" value="<?php echo $first; ?>"/><br/> <strong>Middle Name: </strong> <input type="text" name="MiddleName" value="<?php echo $middle; ?>"/> <strong>Last Name: *</strong> <input type="text" name="LastName" value="<?php echo $last; ?>"/> <strong>Client ID: *</strong> <input type="text" name="ClientID" value="<?php echo $ClientID; ?>"/> <strong>Diagnosis: *</strong> <input type="text" name="Diagnosis" value="<?php echo $Diagnosis; ?>"/> <strong>Gender: *</strong> <input type="text" name="Gender" value="<?php echo $Gender; ?>"/> <strong>Level <span class="posthilit">of</span> Care: *</strong> <input type="text" name="LevelCare" value="<?php echo $LevelCare; ?>"/> <strong>Counselor: *</strong> <input type="text" name="Counselor" value="<?php echo $Counselor; ?>"/> <p>* required</p> <input type="submit" name="submit" value="Submit" /> </div> </form> </body> </html> <?php } /* EDIT RECORD */ // if the 'id' variable is set in the URL, we know that we need to edit a record if (isset($_GET['id'])) { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { // make sure the 'id' in the URL is valid if (is_numeric($_POST['id'])) { // get <span class="posthilit">variables</span> from the URL/form $id = $_POST['id']; $FirstName = htmlentities($_POST['FirstName'], ENT_QUOTES); $MiddleName = htmlentities($_POST['MiddleName'], ENT_QUOTES); $LastName = htmlentities($_POST['LastName'], ENT_QUOTES); $ClientID = htmlentities($_POST['ClientID'], ENT_QUOTES); $Diagnosis = htmlentities($_POST['Diagnosis'], ENT_QUOTES); $Gender = htmlentities($_POST['Gender'], ENT_QUOTES); $LevelCare = htmlentities($_POST['LevelCare'], ENT_QUOTES); $Counselor = htmlentities($_POST['Counselor'], ENT_QUOTES); // check that FirstName, LastName and ClientID are not empty if ($FirstName == '' || $MiddleName == '' || $LastName == '' || $ClientID == '' || $Diagnosis == '' || $Gender == '' || $LevelCare == '' || $Counselor == '') { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($FirstName, $MiddleName, $LastName, $ClientID, $Diagnosis, $Gender, $LevelCare, $Counselor, $error, $id); } else { // if everything is fine, update the record in the database if ($stmt = $mysqli->prepare("UPDATE clients SET FirstName = ?, MiddleName = ?, LastName = ?, ClientID = ?, Diagnosis = ?, Gender = ?, LevelCare = ?, Counselor = ? WHERE id=?")) { $stmt->bind_param("ssssssssi", $FirstName, $MiddleName, $LastName, $ClientID, $Diagnosis, $Gender, $LevelCare, $Counselor, $id); $stmt->execute(); $stmt->close(); } // show an error message if the query has an error else { echo "ERROR: could not prepare SQL statement."; } // redirect the user once the form is updated header("Location: view-paginated.php"); } } // if the 'id' variable is not valid, show an error message else { echo "Error!"; } } // if the form hasn't been submitted yet, get the info from the database and show the form else { // make sure the 'id' value is valid if (is_numeric($_GET['id']) && $_GET['id'] > 0) { // get 'id' from URL $id = $_GET['id']; // get the record from the database if($stmt = $mysqli->prepare("SELECT * FROM clients WHERE id=?")) { $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($id, $FirstName, $MiddleName, $LastName, $ClientID, $Diagnosis, $Gender, $LevelCare, $Counselor); $stmt->fetch(); // show the form renderForm($FirstName, $MiddleName, $LastName, $ClientID, $Diagnosis, $Gender, $LevelCare, $Counselor, NULL, $id); $stmt->close(); } // show an error if the query has an error else { echo "Error: could not prepare SQL statement"; } } // if the 'id' value is not valid, redirect the user back to the view.php page else { header("Location: view.php"); } } } /* NEW RECORD */ // if the 'id' variable is not set in the URL, we must be creating a new record else { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { // get the form data $FirstName = htmlentities($_POST['FirstName'], ENT_QUOTES); $MiddleName = htmlentities($_POST['MiddleName'], ENT_QUOTES); $LastName = htmlentities($_POST['LastName'], ENT_QUOTES); $ClientID = htmlentities($_POST['ClientID'], ENT_QUOTES); $Diagnosis = htmlentities($_POST['Diagnosis'], ENT_QUOTES); $Gender = htmlentities($_POST['Gender'], ENT_QUOTES); $LevelCare = htmlentities($_POST['LevelCare'], ENT_QUOTES); $Counselor = htmlentities($_POST['Counselor'], ENT_QUOTES); // check that FirstName and LastName are both not empty if ($FirstName == '' || $MiddleName == '' || $LastName == '' || $ClientID == '') { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($FirstName, $MiddleName, $LastName, $ClientID, $Diagnosis, $Gender, $LevelCare, $LevelCare, $Counselor, $error); } else { // insert the new record into the database if ($stmt = $mysqli->prepare("INSERT clients (FirstName, MiddleName, LastName, ClientID, Diagnosis, Gender, LevelCare, Counselor) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")) { $stmt->bind_param("ssssssss", $FirstName, $MiddleName, $LastName, $ClientID, $Diagnosis, $Gender, $LevelCare, $Counselor); $stmt->execute(); $stmt->close(); } // show an error if the query has an error else { echo "ERROR: Could not prepare SQL statement."; } // redirec the user header("Location: view.php"); } } // if the form hasn't been submitted yet, show the form else { renderForm(); } } // close the mysqli connection $mysqli->close(); ?>
  17. hello, so i've been developing this website ( http://www.ultimate-dimension.co.uk/NewRAL/store1.php ) for a while now, and the owner wanted a shopping cart implemented. However another coder began the coding of this shopping cart. The cart works perfectly besides that fact that after the Paypal payment as been made I cannot make the system redirect the user to a page where they can download the files that they have ordered. Here is the shopping cart code... <?php session_start(); $page = 'store1.php'; if (isset($_GET['add'])) { $quantity = mysql_query('SELECT id, quantity FROM filesTable WHERE id='.mysql_real_escape_string((int)$_GET['add'])); while ($quantity_row = mysql_fetch_assoc($quantity)) { if ($quantity_row['quantity']!=$_SESSION['cart_'.(int)$_GET['add']]) { $_SESSION['cart_'.(int)$_GET['add']]+='1'; } } header('location:'.$page); } if (isset($_GET['remove'])) { $_SESSION['cart_'.(int)$_GET['remove']]--; header('location:'.$page); } if (isset($_GET['delete'])) { $_SESSION['cart_'.(int)$_GET['delete']]='0'; header('location:'.$page); } function products() { $get = mysql_query('SELECT id, name, description, price, shipping FROM filesTable WHERE quantity > 0 ORDER BY id DESC'); if (mysql_num_rows($get)==0) { echo "There are no products to display :/"; } else { while ($get_row = mysql_fetch_assoc($get)) { echo '<p>'.$get_row['name'].'<br />'.$get_row['description'].'<br /> &pound'.number_format($get_row['price'], 2).' <br /> <a href="cart.php?add='.$get_row['id'].'">ADD</a></p> <br /><hr><br />'; } } } function paypal_items() { $num==0; foreach ($_SESSION as $name => $value) { if ($value!=0) { if (substr($name, 0, 5)=='cart_') { $id = substr($name, 5, strlen($name)-5); $get = mysql_query('SELECT id, name, price, shipping FROM filesTable WHERE id='.mysql_real_escape_string((int)$id)); while ($get_row = mysql_fetch_assoc($get)) { $num++; echo '<input type="hidden" name="item_number_'.$num.'" value="'.$id.'">'; echo '<input type="hidden" name="item_name_'.$num.'" value="'.$get_row['name'].'">'; echo '<input type="hidden" name="amount_'.$num.'" value="'.$get_row['price'].'">'; echo '<input type="hidden" name="shipping_'.$num.'" value="'.$get_row['shipping'].'">'; echo '<input type="hidden" name="shipping2_'.$num.'" value="'.$get_row['shipping'].'">'; echo '<input type="hidden" name="quantity_'.$num.'" value="'.$value.'">'; } } } } } function cart() { foreach ($_SESSION as $name => $value) { if ($value>0) { if (substr($name, 0, 5)=='cart_') { $id = substr($name, 5, (strlen($name)-5)); $get = mysql_query('SELECT id, name, description, price, shipping FROM filesTable WHERE id='.mysql_real_escape_string((int)$id)); while ($get_row = mysql_fetch_assoc($get)) { $sub = $get_row['price']*$value; echo $get_row['name'].' x '.$value.' @ &pound'.number_format($get_row['price'], 2).' = &pound'.number_format($sub, 2).' <a href="cart.php?remove='.$id.'">[ - ]</a> <a href="cart.php?add='.$id.'">[ + ]</a> <a href="cart.php?delete='.$id.'">[ DELETE ]</a> <br><br>'; } } $total += $sub; } } if ($total==0) { echo "Your cart is empty :/"; } else { echo '<br><p class="rightAlignCart">Total: £'.number_format($total, 2).'</p>'; ?> <p> <form class="rightAlignCart" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="joshlittlewood@ultimate-dimension.co.uk"> <?php paypal_items(); ?> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="amount" value="<?php echo $total; ?>"> <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but06.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> </p> <?php } } ?> By the way the store is running in sandbox mode, for anyone who wants to try it. I believe that Paypal's IPN is the way to do it, but I just can't get it to work with the current shopping cart system. Any help on how do do this would be greatly appreciated!
  18. I am trying to create a "login" webpage. The PHP codes for the login (login100.php) are called by another file (index100.php). Whenever I run index100.php on XAMPP, I get two errors: Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\login100.php on line 24 Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\login100.php on line 26 My codes for index.php are: <?php include('login100.php'); // Includes Login Script if(isset($_SESSION['login_user'])){ header("location: profile100.php"); } ?> <!DOCTYPE html> <html> <head> <title>Login Form in PHP with Session</title> <link href="style100.css" rel="stylesheet" type="text/css"> </head> <body> <div id="main"> <h1>PHP Login Session Example</h1> <div id="login"> <h2>Login Form</h2> <form action="" method="post"> <label>UserName :</label> <input id="name" name="username" placeholder="username" type="text"> <label>Password :</label> <input id="password" name="password" placeholder="**********" type="password"> <input name="submit" type="submit" value=" Login "> <span><?php echo $error; ?></span> </form> </div> </div> </body> </html> My codes for login.php are: <?php session_start(); // Starting Session $error=''; // Variable To Store Error Message if (isset($_POST['submit'])) { if (empty($_POST['username']) || empty($_POST['password'])) { $error = "Username or Password is invalid"; } else { // Define $username and $password $username=$_POST['username']; $password=$_POST['password']; // Establishing Connection with Server by passing server_name, user_id and password as a parameter $connection = mysqli_connect("localhost", "root", "", "Company"); // To protect MySQL injection for Security purpose $username = stripslashes($username); $password = stripslashes($password); $username = mysqli_real_escape_string($connection, $username); $password = mysqli_real_escape_string($connection, $password); // SQL query to fetch information of registerd users and finds user match. $sql = "SELECT * FROM login where password='$password' AND username='$username'"; $query = mysqli_query($connection, $sql); if (false === $query) { echo mysqli_error(); } $rows = mysqli_num_rows($query); if ($rows == 1) { $_SESSION['login_user']=$username; // Initializing Session header("location: profile100.php"); // Redirecting To Other Page } else { $error = "Username or Password is invalid"; } mysqli_close($connection); // Closing Connection } } ?> I have worked on this for the past FIVE days and I cannot resolve this issue. All I want is a code which fetches a user's username and password from the database, and no such username or password exist, a message saying "invalid password" is generated. For some reason, I'm getting the two error messages above. Can someone help?
  19. Hey there guys. I want first to thank you for helping me in my previous topic : http://forums.phpfreaks.com/topic/294511-not-saving-session-data-after-log-in/ But now i did not run throw a code problem yet throw a diff type of problems. After reading the "posting rules" or forgot what it name was i realize that this post is probably a bad idea. But here is the problem. I am working on a system that can read the files of a my server witch i have in my home. Yet after searching for days litterly i couldn't find any way or functions or even a hint to build a php function in order to read the files in the directory of the server. So all i ask for is not for you to write any bit of code or any thing just if you know even a small bit of what im looking for to post it as a reply so i can finish my project . Or if you know any tutorials on it. After all i don't just want it to work but to also understand what is going on. Thanks for reading.
  20. Good Day, So this is the scenario. i have two tables Organization, and Course, so in organization.tbl i have org_name, org_description, and course_id and in course.tbl i have course_id, course_name. there is no problem in inserting the org_name and org_description but i have a problem in inserting the multiple course_id into organization.tbl This is my checkbox script. <?php $query = "SELECT * FROM course"; $result = mysql_query($query); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { ?> <input type="checkbox" name="course" value="<?php echo $line["course_name"]?>"> <?php echo $line["course_name"]?> <br> <?php } ?> now how to insert multiple course id into org.tbl this is my query in saving the course_id. <?php if (isset($_POST['save'])) { $course_id = $_POST['course_id']; mysql_query("insert into organization (course_id) values ('$course_id') ") or die(mysql_error()); } ?>
  21. I must use a hyperlink like this: <a href="https://www.pic-vert.fr/obm/availabilitycalendar.php?id=1&month=2&year=2015&ln=nl"> I want to make it dynamic so that month=2 changes into month='current month' and year = 2015 changes into year = current year. Any help available ? Thanks a lot, Freddy (beginner)
  22. Hi, wish somebody can help me T_T I'm little bit confused how to make user log-in based on country or territory, what I'm talking about is like this: The User table is: id_user | username | password | level | id_country The Country table is: id | country_name And when user login, there's a data entry form and there is a drop-down/combo-box in a form, that filled with user countries, like this: Country: [____] --> This part is automatically filled/disabled field if a user log-in with their username based on level and countries. Province: [____] --> This is a chained combo-box from countries City: [____] --> Also this chained to Province What I mean is, when user's log-in with their country id, so the "Country Combo-Box" will be automatically filled and disabled. So user can't choose another country, only their country based on username and territories. Thank you for all your help. Best regards, Kris I have this scripts: login_form.php <div><center> <form name="logForm" method="post" action="login_validation.php"> <table class="table-list" width="500" border="0" cellpadding="2" cellspacing="1" bgcolor="#999999"> <tr> <td width="106" rowspan="5" align="center" bgcolor="#CCCCCC"><img src="images/padlock.png" width="116" height="75" /></td> <th colspan="2" bgcolor="#CCCCCC"><b>LOGIN FORM </b></td> </tr> <tr> <td width="117" bgcolor="#FFFFFF"><b>Username</b></td> <td width="263" bgcolor="#FFFFFF"><b>: <input name="txtUser" type="text" size="30" maxlength="20" /> </b></td> </tr> <tr> <td bgcolor="#FFFFFF"><b>Password</b></td> <td bgcolor="#FFFFFF"><b>: <input name="txtPassword" type="password" size="30" maxlength="20" /> </b></td> </tr> <tr> <td bgcolor="#FFFFFF"><b>Access Level</b></td> <td bgcolor="#FFFFFF"><b>: <select name="comboLevel"> <option value="BLANK">- Choose -</option> <?php $level = array("operator", "admin"); foreach ($level as $p) { if ($_POST['comboLevel']==$p) { $check="selected"; } else { $check = ""; } echo "<option value='$p' $check>$p</option>"; } ?> </select> </b></td> </tr> <tr> <td bgcolor="#FFFFFF"> </td> <td bgcolor="#FFFFFF"><input type="submit" name="btnLogin" value=" Login " /></td> </tr> </table> </form> </center></div> and this validation script: login_validation.php <?php if(isset($_POST['btnLogin'])){ $msgError = array(); if ( trim($_POST['txtUser'])=="") { $pesanError[] = "Username </b> cannot empty !"; } if (trim($_POST['txtPassword'])=="") { $msgError[] = "Password </b> cannot empty !"; } if (trim($_POST['comboLevel'])=="BLANK") { $msgError[] = "Level</b> not picked !"; } $txtUser = $_POST['txtUser']; $txtUser = str_replace("'","´",$txtUser); $txtPassword=$_POST['txtPassword']; $txtPassword= str_replace("'","´",$txtPassword); $comboLevel =$_POST['comboLevel']; if (count($msgError)>=1 ){ echo "<div class='mssgBox'>"; echo "<img src='images/exclamation.png'> <br><hr>"; $noMsg=0; foreach ($msgError as $index=>$show_msg) { $noMsg++; echo " $noMsg. $show_msg<br>"; } echo "</div> <br>"; include "login.php"; } else { $loginSql = "SELECT * FROM user WHERE username='".$txtUser."' AND password='".md5($txtPassword)."' AND level='$comboLevel'"; $loginQry = mysql_query($loginSql, $conndb) or die ("Query Error : ".mysql_error()); if (mysql_num_rows($loginQry) >=1) { $loginData = mysql_fetch_array($loginQry); $_SESSION['SES_LOGIN'] = $loginData['id_user']; $_SESSION['SES_USER'] = $loginData['username']; if($comboLevel=="admin") { $_SESSION['SES_ADMIN'] = "admin"; } if($comboLevel=="operator") { $_SESSION['SES_OPERATOR'] = "operator"; } // Refresh echo "<meta http-equiv='refresh' content='0; url=?page=Main-Page'>"; } else { echo "You Not Login As ".$_POST['comboLevel']; } } } ?> Thank you for all help.... T_T thank you..
  23. I would like to know how can I redirect a jquery dialog function to a different page, if another function is true? For eg. 1. User 1 sends a request to User 2. 2. User 2 accepts the request. 3. User 1 still has the request "dialog" window open. Instead, I would like to have that dialog window close and redirect to a specified page. Of course this only happens after User 2 accepts the request and I check against it in the database. Here is the function for when User 1 makes a request. <script> $(function() { $("#new-dialog").dialog({ resizable: true, autoOpen: false, modal: true, width: 600, height: 300, buttons: { "Cancel Trade": function(e) { $(this).dialog("close"); $.ajax({ type:"post", url:"request-trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>", data:"action=cancelTrade", success:function(data){ if(data == true) { alert('success'); } else { alert('not deleted'); } //window.location.href='trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>'; } }); } } }); $(".dialogify").on("click", function(e) { e.preventDefault(); $("#new-dialog").html(""); $("#new-dialog").dialog("option", "title", "Loading...").dialog("open"); $("#new-dialog").load(this.href, function() { $(this).dialog("option", "title", $(this).find("h1").text()); $(this).find("h1").remove(); }); }); }); </script> And here is the new function in which I check the database for match. If it returns true, I would like to redirect the above dialog/page. <script> $('document').ready(function(){ function checkTrade() { $.ajax({ type:"post", url:"request-trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>", data:"action=checkTrade", success:function(data){ window.location.href='trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>'; } }); } }); </script> So what am I missing to do the redirect?
  24. hi everyone, thanks in advance. i have one issue regarding cookie based authentication with curl. i have an application which calls a third party php url for user registration and authentication. when we called athentication with third party url using curl the result shows succes and cookie is building. again i need to call another url from same third party server which displays a flash. once the authentication is success the flash automatically logins. but for me flash ask for username and password, it should n't be like that. i hope my curl call not building cookie in right format. please check my code and give suggestions. <?php $result=$name=$pass=""; $name= $_SESSION["name"]; $pass=$_SESSION["pass"]; $ch = curl_init(); $cookie_file_path = 'my_cookie.txt'; $cookie_file_path = realpath($cookie_file_path); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path); curl_setopt($ch, CURLOPT_VERBOSE, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //new ones curl_setopt($ch, CURLOPT_HEADER, 1); // here i am calling third party url for athentication curl_setopt($ch, CURLOPT_URL,"http://thirdpartyserver.com/checksession.php?username=".$name."&passme=".$pass); $result= curl_exec ($ch); if ($result==true) { //here i am calling the third party flash which is embed in this page. flash should automatically login with cookie. header( "refresh:1;url= http://myserver/testfolder/flashLoader.php" ); } ?> please let me my code is correct, and thanks for your suggestions. thanks vinz
  25. Hi all, I need some guidance and hoping some of you might be able to point me in the right direction. I am working on a project for a client that includes a very large database of business contacts and a simple one line search box. I will explain as best I can: The database contains prefix, first name, last name, company name, company type (roofing, tiling, flooring...etc), address, city, county, zip code, phone number and other variables. The search box on the websites homepage is only one line. The pre-populated text says: Enter Business type, city, county or zipcode. The user is "supposed" to add a type of business (I.e. Roofing, tiling, dry walling ...etc) followed by either a city, a county or a zip code. I need to figure out how to take this text (I.e. Roofing macomb county, or, Roofing 48333, or Roofing Detroit) and first find all companies that match type (roofing) and then match either city, county or zipcode, depending on what the user enters. Traditionally, I have used multi-part search boxes, such as a drop down for company type, text box for city, county or zip, and assigned each as a search variable, easy stuff, but I am unsure as to how I would progress with a single text string that I'm not even sure how a customer will enter. They could, for example, type the zipcode or city first, followed by the company type (I.e. 48333 roofing) or they may not enter a company type at all, simply entering a zip code, in which case I'd have to be able to prompt them to add a company type as well so we know which companies to return. Could anyone please give me some advice on how I should start on this? I have 2 weeks to complete the entire project and this is the only area I am unfamiliar with. The rest is just a lot of coding and pretty standard. Thank you so much in advance!
×
×
  • 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.