Jump to content

christo

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Everything posted by christo

  1. That's it you were right about putting it in the form ! i changed the script too and at least i have the alert now! I still have some probs  like : Warning: mysql_connect(): Can't connect to MySQL server on 'localhost' (10061) in c:\program files\easyphp1-8\www\search.php on line 57 Erreur de connection avec MySQL ! Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in c:\program files\easyphp1-8\www\search.php on line 58 Erreur connection avec la DB ! Warning: mysql_query(): Can't connect to MySQL server on 'localhost' (10061) in c:\program files\easyphp1-8\www\search.php on line 68 That might be that i have to configure easyphp  ???
  2. but in the form i have already the action for the php script, where/ can i add this too ?
  3. the problem with the onClick is that if the user hits enter at the keyboard and not use the mouse then the js won't do anything...that why i'm not using it. But i will do the changes that you talked about and hope for the best, thank eh !
  4. Hi to everybody ! I'm writing an html page where the user fils one or more (if zero infos then pop up Alert) forms (javascript check) and then the page sends the info to a php scipt for treatment and then database check (mysql). What i don't know is this : Since with the form action = script.php to send the infos then where do i place the javascript ? Here's what i've donne but it doesn't work. [code] <html>     <head>         <title> * Annuaire * </title>             <script type="text/javascript">                 function verifForm(formulaire){                     if( formulaire.name.value == "")                     alert('Le champ est vide !!!');                         else                             formulaire.submit();} </script>     </head>         <body>             <h2 style = "text-align": center;></div>             <h2 style = "text-align": center;> * Annuaire du xyz * </h2>                             <form action = search.php method = "POST">                     <table border=\"0\">                                         <tr><td>Nom :</td> <td><input type="text" name="name"></td></tr> <tr><td>Prenom :</td> <td><input type="text" name="surname"></td></tr> <tr><td>Tel:</td> <td><input type="text" name="tel" maxlength="10"></td></tr> <tr><td>Email:</td> <td><input type="text" name="email"></td></tr> <tr><td>Web :</td> <td><input type="text" name="web"></td></tr> <td>Departement:</td><td align="center"><select name="depart" > <option value="all" selected="selected">Tous les departements</option> <option >Info</option> <option >Micro</option> <option >Robo</option> <option >Admin</option>                         </select> </td> </tr> <td>Statut:</td><td align="center"><select name="statut" > <option value="all" selected="selected">Tout statut</option> <option >Permanent</option> <option >Doc</option> <option >Post-Doc</option> <option >Invite</option> <option >Stagiaire</option>                         </select> </td> </tr>                 <td><br><input type="submit" value="Envoye" onsubmit="verifForm(this.form)"></input></td>     <td><br><input type="reset" value="Retablir"></input></td>       </form>     </table>     <body> <html>[/code] What do you think ? is the js well placed and why doen't it do anything ? thanks
  5. What i would like to do here is to retrieve the infos of a row in a DB and display it in a form (the same i entered the data) correct them and save . Here's what i've done [code]<? session_start(); if(!isset($HTTP_SESSION_VARS['valid_user'])) {     echo "blablah"; }     else{         echo "Welcome $HTTP_SESSION_VARS[valid_user] <html>         <title>* Blah *</title>     <body>          $objid = $HTTP_POST_VARS['objid']; echo"objid=$objid"; $host = ""; $user = ""; $pass = ""; $base = ""; $db_conx = mysql_connect($host,$user,$pass) or print("error de connection mysql"); mysql_select_db($base, $db_conx) or print("error connection base"); $query ="UPDATE object SET region state city='$city' district='$_POST[district]'accomodation transaction nb_rooms floor price='$_POST[price]' garage cellar garden pool descr='$_POST[descr]'age_par pic WHERE username='".$HTTP_SESSION_VARS['valid_user']."'AND objid='$objid'"; $result = mysql_query($query) or die(mysql_error());     if ($resultat) {         echo"updated !";     }         else {             echo" problem !";         } } ?>[/code] But honestly i haven't understood the concept...Do i need to write 2 requests? (display,update)How can get the infos from the DB and show the values appearing in the form (another php that i enter infosin the DB from, tx radio, checkbox) ?? What do you think of the above script, am i in the right way ??? Any info on this subject is welcome, Thanks Christos
  6. sorted ,no need for * at the request ...
  7. K problem sorted but there is another one :) I manage to pass the value but it won't delete the row from the DB... [code]$objid = $HTTP_POST_VARS['objid']; echo"objid=$objid"; //connection $db_conx = mysql_connect($host,$user,$pass) or print("error de connection mysql"); mysql_select_db($base, $db_conx) or print("error connection base"); $query="DELETE * FROM object WHERE objid=$objid"; $resultat=mysql_query($query); if ($resultat) { echo"deleted !"; } else { echo" problem !"; } My request seems ok,right?
  8. hmm i don't understand your point ! Myself i send data via post and it should work normally, do you mean i should try $_REQUEST (i tried it) the isset thing is no use for me...or maybe i don't see what you're trying to explaing me :( Can you be more clear ? christos
  9. This time from scrip1.php i need to press a button and it will send a value (number) to another script2.php that will erase a row from the DB so at script1.php i have :[code] echo "    </table><br> <td><form method=post action=upd_obj.php> <input type=submit value='Modifier une annonce '> N°: <input type=text name=objid size=1></form></td>";[/code] //the value i need to sent is objid...a box next to N and at script2.php :[code] $objid = $HTTP_POST_VARS['objid']; // in order to bring the value submited by post...at thisline a get the Notice too :( //conncetion with DB $query="DELETE * FROM  object WHERE objid=$objid"; $resultat=mysql_query($query); [/code] The message i get... [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Notice: Undefined index: objid in c:\foreign\easyphp1-8\www\agence\test\del_obj.php on line 21[/quote] what have i done wrong, any ideas ??? Christos
  10. Well i would like to know if i can use OR at my requests... [code]$query = "SELECT * FROM object WHERE city = '$city' AND transaction = '$transaction' AND accomodation = '$accomodation' AND nb_rooms = '$nb_rooms' AND price = '$price' AND age_par = '$age_par'";[/code] for exemple replacing AND with OR above. Would that work ? I haven't found much on the net about it:( christos
  11. First step start from the tutorial of this site (for exemple) and try to customize the code for your own needs. Read read read and start from making small blocks of code and go bigger... No easy way from my experience ! christos
  12. I didn't think that would wok !!! 1000 Thanks :-) christos
  13. That's it ;-) When i try to display the data from the DB i get an endles While loop with an error... [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\foreign\easyphp1-8\www\agence\test\search.php on line 31[/quote] [code] $query = "SELECT * FROM object WHERE city = '$city' AND transaction = '$transaction' AND accomodation = '$accomodation' AND nb_rooms = '$nb_rooms' AND price = '$price' AND age_par = '$age_par'"; $rs = mysql_query($query) or die ('Probleme avec la requette :'.$query.'<br><br>'.mysql_error()); while(($data=mysql_fetch_array($query))!==false) {                   //I get the Warning here     echo "<tr>     <td>".$data['city']."</td>         <td>".$data['transaction']."</td>     <td>".$data['accomodation']."</td>     <td>".$data['nb_rooms']."</td>     <td>".$data['price']."</td>     <td>".$data['age_par']."</td>     </tr>"; } [/code] Any ideas???
  14. Once again i'm passing values from html to php but the request is not working and gives [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Problem with query: SELECT * FROM object WHERE city = Montpellier AND transaction = Location AND accomodation = Maison AND nb_rooms = 6 AND price = 1650000 AND age_par = Agence Unknown column 'Montpellier' in 'where clause'[/quote] i'm passing the values with [code]$city = $HTTP_POST_VARS['city']; $transaction = $HTTP_POST_VARS['transaction']; $accomodation = $HTTP_POST_VARS['accomodation']; $nb_rooms = $HTTP_POST_VARS['nb_rooms']; $age_par  = $HTTP_POST_VARS['age_par']; $price = $HTTP_POST_VARS['price'];[/code] at the top of the script and my request is [code] $host = "???"; $user = "???"; $pass = "???"; $base = "???"; $db_conx = mysql_connect($host,$user,$pass) or print("error connection  MySQL !"); mysql_select_db($base, $db_conx) or print("Error connection  DB !"); $query = "SELECT * FROM object WHERE city = $city AND transaction = $transaction AND accomodation = $accomodation AND nb_rooms = $nb_rooms AND price = $price AND age_par = $age_par"; $rs = mysql_query($query) or die('Problem with query: '.$query.'<br><br>'.mysql_error());[/code] I need to check if the values i'm passing exist in the DB and if yes show results, but i wonder if linking all the vals with AND is the correct way to go... ?
  15. damnnn i'm bad lol... I must be tired, i will take a break...yeah he he he Well that's it sorted (well a big part is yours [b]kenrbnsn[/b]) Thanks christos
  16. I like the precisions of mysql_error, thanks for the tip ;) This is the new (same) error but it's strainge because it's not a complicated request... so idon't see where could the error be...hmmmm [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Problem with query: SELECT * FROM object region='colorado' 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 '='colorado'' at line 1 [/quote] christos
  17. True truei was dumb not to see, it wouldn't work because sinmple there is no post, submit thing on the html form...i also noticed that $_REQUEST works also ;) The problem with the DB is till there though...[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\foreign\easyphp1-8\www\agence\test\reg_map.php on line 23[/quote] which is[code]$query=mysql_query("SELECT * FROM  object region='".$_GET['region']."'"); //if...error else show result $check_reg = mysql_num_rows($query);  // at this point i get Warning if($check_reg == 0) {     echo "no offers for '$region'.<br>         <a href=\"reg_map.html\">back</a><br><br>";     }     else {         while(($data=mysql_fetch_array($query))!==false) {         echo "<tr>         <td><a href=\"full_obj.php\">".$data['objid']."</a></td>         <td>".$data['region']."</td>         <td>".$data['city']."</td>         <td>".$data['accomodation']."</td>         <td>".$data['transaction']."</td>         <td>".$data['price']."</td>         <td>".$data['age_par']."</td>         <td>".$data['date_aj']."</td>         </tr>";     } }[/code] Why doesn't it understan the affectation? Do you think the while will work in this place i have it?
  18. hmm nope it gives errors...Could you take a look at my code please ? <A quick sum : the html needs to pass region, something to php and this one will do a request at the DB to show any results> HTML :[code]<html>     <head>         <title>* Regions  *</title>     </head> <body> <div style="position:absolute;top:40px;left:250px;width:100%;text-align:center;"> <a href="search.html">Retour </a></div> <div style="position:absolute; top:30px;left:100px;"> <A name="map">     <h3>Region map</h3>       <div>         <div align="center"><img src="regions.gif" width="400" height="395" vspace="10" border="3" usemap="#Map" >           <map name="Map">           <area shape="poly" coords="5,116,37,114,46,124,69,123,69,128,77,129,76,144,71,152,67,147,61,152,55,151,53,156,47,159,39,166,27,162,3,144,3,116" href="reg_map.php?[color=#FF0000]region=texas[/color]">           <area shape="poly" coords="64,91,77,94,79,102,98,108,107,104,106,120,116,129,113,142,101,132,95,133,94,129,81,132,69,128,69,109" href="reg_map.php?[color=#FF0000]region=colorado[/color]">.......some more of those....</map>         </div>       </div> </body> </html>[/code] PHP receiving the region, something :[code]<? //to get the value from html $region = $HTTP_POST_VARS['region'];  //At this point a get a Notice echo" <html>         <title>* Offers / region *</title>     <body>         <table border=\"1\">         <tr><td>Annonce # :</td><td>Region :</td><td>town :</td></td><td>Type :</td>             <td>Transaction :</td><td>Price :</td><td>agency:</td><td>Date  :</td>         </tr>"; $host = "???"; $user = "???"; $pass = "???"; $base = "???"; //DB connection $db_conx = mysql_connect($host,$user,$pass) or print("error connection mysql"); mysql_select_db($base, $db_conx) or print("error connection base"); $query=mysql_query("SELECT * FROM  object region='".$_GET['region']."'"); //if...error else show result $check_reg = mysql_num_rows($query);  // at this point i get Warning if($check_reg == 0) {     echo "no offers for '$region'.<br>         <a href=\"reg_map.html\">back</a><br><br>";     }     else {         while(($data=mysql_fetch_array($query))!==false) {         echo "<tr>         <td><a href=\"full_obj.php\">".$data['objid']."</a></td>         <td>".$data['region']."</td>         <td>".$data['city']."</td>         <td>".$data['accomodation']."</td>         <td>".$data['transaction']."</td>         <td>".$data['price']."</td>         <td>".$data['age_par']."</td>         <td>".$data['date_aj']."</td>         </tr>";     } } [/code] But it produces those faults [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Notice: Undefined index: region in c:\foreign\easyphp1-8\www\agence\test\reg_map.php on line 2 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\foreign\easyphp1-8\www\agence\test\reg_map.php on line 23 [/quote] since i'm under php 4.3 maybe i should use $HTTP_POST_VARS instead of $_GET no? i'm not sure i'm a bit comfuzed...
  19. 1) sorted thanks :) the real problem remain though, that's where i have most difficulties... 2)At the reg_map.php i want to get the region, something and do a query the DB something like : CODE $query=mysql_query("SELECT * FROM object WHERE region='".$HTTP_POST_VARS['region']."'"); how does this look like? christos p.s it sounds ridiculous to ask if it will work but it's because i'm not done with the display results :) p.s working under win xp and php 4.3
  20. Here we go again with another subject ! 1 )I have an image map in html and i want to pass values to a php script... exemple : [code]<area shape="poly" coords="257,335,255,344,240,352,241,365,256,384,261,379,261,363,261,348" href="reg_map.php">[/code] so this is a region called corsica and i want to send the 2 values, region and a name let's say corsica, to the reg_map.php knowing that region will be stable and the name will change corsica, texas,cafifornia etc...depends where the users click...They can click further and it will be perhaps region , montana How do i do this??? will it work if i go [code]<area shape="poly" coords="257,335,255,344,240,352,241,365,256,384,261,379,261,363,261,348" href="reg_map.php"?region=Colorado> [/code] 2)At the reg_map.php i want to get the region, something and do a query the DB something like : [code]$query=mysql_query("SELECT * FROM  object WHERE region='".$HTTP_POST_VARS['region']."'"); [/code] how does it look like? christos p.s it sounds ridiculous to ask if it will work but it's because i'm not done with the display results :) p.s working under win xp and php 4.3
  21. It worked even with the pass problem finally but i leant something new too !!! So problem solved :-) Thanks christos
  22. Hmm it's not very clear ...at the tutorial (http://www.phpfreaks.com/tutorials/40/8.php) they don't seem to initialise $pass with something and it still works...for other users :) So i keep getting this[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Notice: Undefined variable: pass in c:\foreign\easyphp1-8\www\agence\test\pasoub.php on line 48[/quote] Any other ideas ??? P.S Otherwise the 2 tips about the database and the php.ini -> corrected Thumbs up !!! christos
  23. I'm trying to make work a script from this site's (members) tutorials ...http://www.phpfreaks.com/tutorials/40/8.php to learn how the mail function works but i keep getting 2 errors [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Notice: Undefined variable: pass in c:\foreign\easyphp1-8\www\agence\test\pasoub.php on line 48 Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in c:\foreign\easyphp1-8\www\agence\test\pasoub.php on line 74 Your password has been sent! Please check your email![/quote] Finally the 2 files: PasOub.html [code]<html>     <form  method="post" action="PasOub.php">         <table width="50%" border="0" cellspacing="0" cellpadding="4">             <tr><td>Please enter your email address</td>             <td><input name="email" type="text"></td></tr>             <tr><td>&nbsp;</td>             <td><input name="recover" type="hidden" value="recover">             <input type="submit" name="Submit" value="Recover My Password!"></td></tr>         </table>     </form> </html>[/code] PasOub.php [code]<? session_start(); $email  = $HTTP_POST_VARS['email']; $host = "???; $user = "???"; $pass = "???"; $base = "???"; $db_conx = mysql_connect($host,$user,$pass) or print("erreur de connection mysql"); mysql_select_db($base, $db_conx) or print("erreur connection base"); switch($_POST['recover']){ default: include 'PasOub.html'; break; case "recover": recover_pw($_POST['email']); break; } function recover_pw($email){ if(!$email){ echo "You forgot to enter your Email address <strong>Knucklehead</strong><br />"; include 'PasOub.html'; exit(); } // quick check to see if record exists $sql_check = mysql_query("SELECT * FROM user WHERE email='$email'"); $sql_check_num = mysql_num_rows($sql_check); if($sql_check_num == 0){ echo "No records found matching your email address<br />"; include 'PasOub.html'; exit(); } // Everything looks ok, generate password, update it and send it! function makeRandomPassword() { $salt = "abchefghjkmnpqrstuvwxyz0123456789"; srand((double)microtime()*1000000); $i = 0; while ($i <= 7) { $num = rand() % 33; $tmp = substr($salt, $num, 1); $pass = $pass . $tmp; $i++; } return $pass; } $random_password = makeRandomPassword(); #$db_password = md5($random_password); #$sql = mysql_query("UPDATE user SET password='$password' #WHERE email='$email'"); $subject = "Your Password at MyWebsite!"; $message = "Hi, we have reset your password. New Password: $random_password http://www.mywebsite.com/login.php Thanks! The Webmaster This is an automated response, please do not reply!"; mail($email, $subject, $message, "From: MyDomain Webmaster<admin@mydomain.com>\n X-Mailer: PHP/" . phpversion()); echo "Your password has been sent! Please check your email!<br />"; } ?>[/code] Of course the mail is not sent and i spent aloooot of time working out diffrent things ... i'm using php 4.3. on windows and i added the line smtp_port=25 at the php.ini do i need to add anything else ? why it doesn't understand $pass ? Christos
  24. Well i replace the code and i get "ERROR: Directory does not exist" which doesn't make since the folder exists (in the same dir with the script)...
  25. That's the new code you suggested sanfly[code]$region = $HTTP_POST_VARS['region']; $state = $HTTP_POST_VARS['state']; $city = $HTTP_POST_VARS['city']; $district = $HTTP_POST_VARS['district']; $accomodation = $HTTP_POST_VARS['accomodation']; $transaction = $HTTP_POST_VARS['transaction']; $nb_rooms = $HTTP_POST_VARS['nb_rooms']; $floor = $HTTP_POST_VARS['floor']; $price = $HTTP_POST_VARS['price']; $garage = (isset($HTTP_POST_VARS['garage']) ? $HTTP_POST_VARS['garage'] : ''); $cellar = (isset($HTTP_POST_VARS['cellar']) ? $HTTP_POST_VARS['cellar'] : ''); $garden = (isset($HTTP_POST_VARS['garden']) ? $HTTP_POST_VARS['garden'] : ''); $pool = (isset($HTTP_POST_VARS['pool']) ? $HTTP_POST_VARS['pool'] : ''); $descr = $HTTP_POST_VARS['descr']; $age_par = $HTTP_POST_VARS['age_par']; $pic = $HTTP_POST_VARS['pic']; $date_aj=date('l dS \of F Y, \a h:i:s A'); $host = "blah"; $user = "blah"; $pass = "blah"; $base = "blah"; $target_path = "\uploads"; if(is_dir($target_path){ #***************** Parse error on this line************************ $target_path = $target_path . basename( $HTTP_POST_FILES['pic']['name']); echo "$target_path<br><br>"; // Uncomment this line to test that the correct path is being used if(move_uploaded_file($HTTP_POST_FILES['pic']['tmp_name'], $target_path)) { echo "The file ". basename( $HTTP_POST_FILES['pic']['name']). " has been uploaded<br>"; $db_conx = mysql_connect($host,$user,$pass) or print("erreur de connection mysql"); mysql_select_db($base, $db_conx) or print("erreur connection base"); $req ="INSERT INTO object VALUES ('', '$region', '$state', '$city', '$district', '$accomodation', '$transaction', '$nb_rooms', '$floor', '$price', '$garage', '$cellar', '$garden', '$pool', '$descr', '$age_par', '$pic', '$date_aj' )"; $result = mysql_query($req) or die(mysql_error()); } else { echo "There was an error uploading the file, please try again!"; } } else { echo "ERROR: Directory does not exist<br><br>"; @unlink($HTTP_POST_FILES['pic']['tmp_name']); }
×
×
  • 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.