Jump to content

ChrisPHP

Members
  • Posts

    30
  • Joined

  • Last visited

Everything posted by ChrisPHP

  1. Ok so I figured out a way for this code to work thanks for Psycho I used echo '<form action="content/QuickSearch.php" method="get">'; $n=$row['Nom_v']; echo '<input type="hidden" value="'.$n.'" name="n" >'; echo "<center><input type=submit value=Reserve id='".$n."' name='".$n."' /></center>"; echo '</form>'; if(isset($_GET['n'])){ $n = $_GET['n']; $sql="SELECT Reserved FROM voiture WHERE Nom_v = '$n' "; $result=mysql_query($sql); $row = mysql_fetch_array($result); $sqll="UPDATE `voiture` SET `Reserved`='1' WHERE Nom_v = '$n' "; $res=mysql_query($sqll,$dbcon); $res=mysql_query($sql,$dbcon); if(!$res) { echo "<html><font size='4' color='white'><b>Can't remove..</b></font></html>"; die(mysql_error()); } else { header('Location: ../Home.php?reserve'); } mysql_close($dbcon); } And it's now fully working Thanks a lot again and again and again all of u:)
  2. @Jessica Well the code won't go through the if(isset) loop and it won't direct to the page set nor it would change the value of the reserved to 1.. I tried debugging the code with firebug and get no errors.. @Psycho Ok I think I get what you mean i'll work on that and i'll keep u updated Thanks a million both of u
  3. I have all the code but it's actually 300 line so I wont actually display it all But I can assure you that the $n and the $row['Nom_v'] actually work and they're defined properly.. I was just wondering if there's a way to work it out because I'm frustrated by it.. If you want just drop it out don't worry I'll probably someday will figure it out lol
  4. @Jessica The $n was defined in $_SESSION['nom_v']= $row['Nom_v']; $n = $_SESSION['nom_v']; mentioned earlier in my first post @Psycho The idea was next each car there's a button... When the button is clicked it will change the row 'reserve' to 1 (to define that the car is reserved) and redirects the user to Home.php?reserved where it will display that the car is successfully reserved.. I'm using Jquery in all of the site but this idea seemed more appropriate like this... :/ Thanks again for your help all of you
  5. Yea I know this code uses a different idea or method.. The original code used to have ths instead of the function Reserve(): <?php if(isset($_POST[$n])){ $sql="SELECT Reserved FROM voiture WHERE Nom_v = '$n' "; $result=mysql_query($sql); $row = mysql_fetch_array($result); $row['Reserved'] = 1; header('Home.php?reserve'); } But it didn't work so I tried this method above
  6. Yea I did this.. but the if(isset($_POST['$n']))... wouldn't actually work when pressing the button..
  7. Oh ok thanks for your quick reply:) My idea was to display all the 'cars' available in a db with a button Reserve for every car with the id = to the name of this car.. I tried the if(isset($_POST['$n'])) and it didn't work either.. Can anyone help me out with this idea please?
  8. Hey everyone, Hope you're feeling good.. I was trying something and I can't seem to work it out.. <form action="content/QuickSearch.php" method="post"> <?php $_SESSION['nom_v']= $row['Nom_v']; $n = $_SESSION['nom_v']; echo "<center><input type=submit value=Reserve id='".$n."' name='".$n."' onmousedown='Reserve(".$n.");'/></center>"; ?> </form> <script> function Reserve(a){ <?php { $sql="SELECT Reserved FROM voiture WHERE Nom_v = '<script>a</script>' "; $row['Reserved'] = 1; header('Home.php?reserve'); } ?> } </script> The session actually works and the button is named properly.. but can I use this method? will it actually work? Because the code doesn't seem to go into the function Reserve ever... Thanks in advance anyway Regards, Chris
  9. Ok I think I know what you're talking about I'll check it out when I'll finish my finals.. I don't expect anyone will help more than that.. Thank you anyways I'll mark this as solved anw...
  10. You're asking about something very general.. I suggest you learn about authentications and redirecting, then if you have a question a little more precise I'd be happy to help you can check this link out also: http://studge.com/create-a-site-authentication-login-with-php-and-mysql/
  11. Hey everyone, I hope that you're doin all great.. So I decided to learn about sql injections more to comprehend how hackers actually think.. Let's say i know the structure of a database for a certain website, it has client as table and username as field and I want to 'hack' my way to the website; I know about ' or '1'='1 and I know how it actually functions.. My question is, can I select a certain row in a field while login in using { or 1= ( SELECT username FROM client ) -- } ? If yes, what's the proper syntax because it's giving a syntax error
  12. Well this topic is somehow old, i did solve my problem eventually.. I used jquery and a lot of debugging and managed to work out my idea Thanks anyways
  13. It did solve my problem thanks a million Just for comprehension.. what does array_shift() actually do? Thanks a lot again
  14. Hello everyone, Hope you're doing all fine I just wanted to ask about something that's happening to me recently.. Whenever I change the name of a file, it automatically adds up Array in the beginning of the name. I just wanted to know if there's a way to prevent it I'm using $target = $target . basename($_FILES['AImage']. $an .'.jpg'); where AImage is the name of the field in mysql and $an is the name that I wanted to put Thanks in advance. Best regards, Chris
  15. Yea it was an honest mistake lol Eventually i used the $('#address1').html... and my code worked fine Thanks everyone
  16. Lol yea I did figured out whats my problem and learned about debugging but I can't still manage to make it work !! Now I'm using firebug to debug my code... getData.php response with the correct values but can't display it in div yet!! my code is now for home.php <html> <head> <?php ini_set('display_errors', 1 ); error_reporting(E_ALL); ?> <script type="text/javascript" src="JQuery.js"></script> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery('#Client_ID').change('change', function(event) { $.ajax({ url : 'getData.php', type : 'POST', dataType: 'json', data : $('#myform').serialize(), success: function( data ) { $("#address1").val( data["address1"] ); $("#address2").val( data["address2"] ); } }); }); }); </script> </head> <body> <form id='myform' action='getData.php' method='post'> <select name='Client_ID' id='Client_ID'> <option value='Roy'>Roy</option> <option value='Ralph'>Ralph</option> </select> <div name='address1' id='address1'></div> <div name='address2' id='address2'></div> </form> </body> </html> and for getData.php <?php ini_set('display_errors', 1); error_reporting(E_ALL); include('Conx.php'); $clientId = $_POST['Client_ID']; $db = "projet"; $query = "SELECT nom, prenom FROM client WHERE nom = '$clientId' "; $result = mysql_query($query); $row = mysql_fetch_array($result); $add1 = $row["nom"]; $add2 = $row["prenom"]; $arr = array( 'address1' => $add1, 'address2' => $add2); echo json_encode( $arr ); ?> I'm really getting frustrated by this issue !!
  17. First of all thanks for your quick reply and sorry about any inconvenience. I didn't know that it was case sensitive so it solved my 2 hours problem lol Thanks a lot!!!!
  18. Hello everyone, I just wanted to know if $.POST function is still usable in Javascript language because I'm receiving "$.POST is not a function" in debugging.... <?php include("Conx.php"); $sql="SELECT nom FROM client"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["nom"]; $options.="<OPTION VALUE=\"$id\">".$id; } ?> <SELECT id="Driver"> <option id="option" name="option" value="">Choose a driver...</option> <?=$options?> </SELECT> <script type="text/javascript"> $(document).ready(function(){ $('#Driver').change(function(){ $.POST("Driver-Modify.php", {nom:$("#Driver").val()}, function(data){ $('input[name="description"]').val(data.description); } ,"json" ); }); }); </script> <?php if(isset($_POST['Driver'])) { $sql = mysql_query("SELECT nom FROM client WHERE nom='" . mysql_real_escape_string($options) . "'"); $row = mysql_fetch_assoc($sql); $arr = array( '#description' => $row['nom']); echo json_encode($arr); } ?> <input type="text" name="description" id="description"/> Thanks in advance. Regards, Chris
  19. Ok I figured out what to do but I still can't get the results from mysql.. When I click on the selected option nothing happens The code now is something like this: main.php <html> <head> <script type="text/javascript" src="../JQuery.js"></script> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery('#Client_ID').live('change', function(event) { $.ajax({ url : 'getData.php', type : 'POST', dataType: 'json', data : $('#myform').serialize(), success: function( data ) { for(var id in data) { $(id).val( data[id] ); } } }); }); }); </script> </head> <body> <form id='myform'> <select name='Client_ID' id='Client_ID'> <option value=''>Select</option> <option value='1'>Roy</option> <option value='2'>Ralph</option> </select> <div name='address1' id='address1'> <div name='address2' id='address2'> </form> </body> </html> [/Code] getData.php: [code=php:0] <?php include('../content/Conx.php'); $clientId = $_POST['Client_ID']; // Selected Client Id $query = "SELECT nom, prenom FROM client where nom = $clientId"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result,projet); $add1 = $row[nom]; $add2 = $row[prenom]; $arr = array( 'div#address1' => $add1, 'div#address2' => $add2); echo json_encode( $arr ); ?> I need help
  20. I think I get what you mean.. Ill try to figure out my code after work! Thanks a million
  21. If there's a way without using a new page to load the infos i'd really appreciate it:) I love the code that you posted.. but how can I use it with mysql? I'm sorry if I'm a noob with this..
  22. Thanks for your quick reply The idea is that I want a part of the page load without refreshing. I can do this with buttons but not with options. Let's say that I have a driver named X existing in mysql.. When I click X from the options I need to show the infos from mysql about this driver without refreshing the page in a div. The problem i'm having that I tried the method that I used with the buttons but it didn't work. When I click the driver X nothing changes in the page (Driver.php wont load in content2)
  23. With the use of Jquery, I need that when choosing an option from Select, it displays directly the information about the option selected from database. The code is a little something like this. Main page: <Table> <form action="content/Driver-Remove.php" method="post" enctype="multipart/form-data"> <TR> <TD> <?php include("Conx.php"); $sql="SELECT nom FROM client"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $id=$row["nom"]; $options.="<OPTION VALUE=\"$id\">".$id; } ?> <SELECT id="Driver"> <option value="0" id="nav2">Choose a driver...</option> <?=$options?> </SELECT> </TD> </TR> <TR> <TD> <center> <input type="submit" value="Remove"> </center> </TD> </TR> <TR> <TD> <div name="content2"> <script src="JQuery.js"></script> <script src="js/general2.js"></script> </div> </form> </Table> [/Code] general2.js: [Code] $(document).ready(function(){ var $dd = $('#Driver'); var $options = $('option', $dd); $options.click(function() { $('#content2').load(Driver.php); return false; }); [/Code] Driver.php will load in <div id=content2> displaying inside the information... Any help?
  24. Hey all, Hope your doing all fine... Ok my next idea is that I have this page that it contains a content. Whenever i click something in menu it loads the proper page inside the content. But when I click a button with the method POST it redirects the whole page and not the content only. I want to display if a driver is successfully added or not inside the same page!! Code of Admin.php: include("Conx.php"); if(isset($_POST['AName']) && isset($_POST['CEOName'])&& isset($_POST['Address']) && isset($_POST['AEmail']) && isset($_POST['ATel'])){ $target = "images/"; $target = $target . basename( $_FILES['AImage']['name']); $an=$_POST['AName']; $cn=$_POST['CEOName']; $a=$_POST['Address']; $ae=$_POST['AEmail']; $at=$_POST['ATel']; $file=$_FILES['AImage']['tmp_name']; $sql="INSERT INTO agence(agID,nom_loueur,adresse,email,tel,AImage)values('".$an."','".$cn."','".$a."','".$ae."','".$at."','".$file."')"; if(move_uploaded_file($_FILES['AImage']['tmp_name'], $target)){ $res=mysql_query($sql) or die(mysql_error()); header('location: ../Admin.php?add'); }else{ echo "<html><font size='4' color='white'><b>Can't insert..</b></font></html>"; } } and in the main page Admin.php added: if(isset($_GET['add'])) { echo "<html><center><font size='4' color='white'><b>Successfuly added!!</b></font></center></html>"; }else{ echo"<html><center><font size='4' color='white'><b>Welcome to Admin's page!!</b></font></center></html>"; } I know that this way gives the result on Admin.php and not inside the content in page chosen... Thanks 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.