Jump to content

l_kris06

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Everything posted by l_kris06

  1. Hi All, Can somebody tell me the functional versions of PHP5 + APache + mysql. In my hurry to upgrade the production server to the latest versions, i upgraded apache to 2.2.11 and php to 5.2.8 and mysql to 5.1 and now when every am calling db through php, i get an httpd.exe application. Rgds, Krishna
  2. <> = lesser than or greater than but not equal to. why are you trying to do "order by" on two columns? your final output is constrained with date. Meaning, you want the entire output of your query to be sorted with latest one on top. $top10 = mysql_query("SELECT votes,date,progname FROM data where prog<>19 ORDER BY date DESC LIMIT 10") or trigger_error("MySQL Error", E_USER_WARNING ); $citizenschool = mysql_query("SELECT votes,date,progname FROM data where prog=19 ORDER BY date DESC LIMIT 1") or trigger_error("MySQL Error", E_USER_WARNING ); The above code will work just fine.
  3. UPDATE table_name SET column1 = column2; where table_name = current table that needs to be manipulated column1 = destination column2 = source; Careful : The above query will copy all that is in column1 to column2. Use the "WHERE" clause to do conditional update. Rgds, Kris
  4. @chronister, Maybe people new to programming might take it in its face value. <?php if($username != $password) {//failed flag , do something}?> . maybe!! but i see wht u mean though. adding more comments should help. Anyways i believe ameharhughes still is in square 1. @ameharhughes, hope this helps. <?php $username = "user"; $password = md5("pass"); /*$username and $password are constants, ideally username and password will be fetched from a user login form page, and when the user presses submit, the entire form will be posted and you can grab the values by using $_POST.*/ /*I am assuming you have a DB called "users" where you have the username and password stored for each user and we assume here that the password has a one way encryption(MD5).*/ $query = "select * from users where username = '$username' and password='$password';"; $success = mysql_query($query); //enforce conditions $returned = mysql_num_rows($success); /* this will have the number of rows returned by the query, and the returned number MUST BE 1 for a success condition, failure will result in 0, and any value greater than 1 indicates a manipulated database */ if($returned == 1){ /*OK, we have a success, the user trying to login is a valid user and can be redirected to main page. We store his username in session file and during all page traversal we call this session file to see who is the current user*/ $_SESSION['curUser'] = $username; header('Location: main.php'); exit; }elseif($returned == 0){ /*Failure flag, username and password failed validation. We store the error message in a session and redirect to the login page, and print the error which is stored in the $_SESSION['err'] session file */ $_SESSION['err'] = "Username and password failed validation."; header('Location: login.php'); exit; }else{ /*query returned more than 1 row, compromised db. Ideally you need to make a file log here and shut down the website*/ } ?>
  5. <?PHP $content .= "<td valign=\"bottom\"><br><a href='admin.php?p=temp_models&id=".$info[tempmodelid]."'><strong>Delete this application</strong></a><br>".$info[name]."<br><a href='mailto:".$info[email]."?subject=Jimmys Promotions and Modelling Agency Model Application'>".$info[email]."</a><br> <a href='images/applications/'".$info[picname]." rel='lightbox'><img src='images/applications/".$info[picname]."' alt='".$info[name]."' width='300'/><a/><br><br></td>"; ?>
  6. What was asked by ameharhughes and my reply was : <?php $username = "user"; $password = "password"; if($username!=$password){ header('Location: login.php'); exit; }else{ header('Location: main.php'); exit; } ?> @chronister , @hobeau The example code that I posted was to help the poster understand how to redirect on a failure flag. It is NOT an actual login script for me to worry about its working modalities. There are lots of secure classes and scripts available that will help him acheive that, a simple google search will help him. wht i was addressing is: And I believe the code I posted is sensible enough to serve the purpose. Edit: Lets not trivialize without actually going through the inherent purpose. Rgds, Kris
  7. <?php $username = "user"; $password = "password"; if($username!=$password){ header('Location: login.php'); exit; }else{ header('Location: main.php'); exit; } ?>
  8. you mean, a website should receive an email, and convert that to a post?? question: Who will the mail be addressed? i guess you can set up bots that can monitor a certain mailbox, and on reception parse it and convert it to a post by inserting those values in the relavant db, but u still need to understand who the TO is to get this working, once you figure that, this will be straight forward. Rgds, Kris
  9. Hi, Define help ? what are you really looking for, if you could post what you want, that would help people get an idea and in turn might be able to help. :)Rgds, Kris
  10. Fixed: <?php session_start(); $style = $_POST['styles']; $_SESSION['style'] = $style; ?> <?php if($_SESSION['style'] == "green"){ $styles = "styles/green/style.css"; }elseif($_SESSION['style'] == "red"){ $styles = "styles/red/style.css"; }elseif($_SESSION['style'] == "blue"){ $styles = "styles/blue/style.css"; }else{} if(!isset($_SESSION['style'])){ $styles = "styles/green/style.css"; } ?> <form method="post" action=""> <select name="styles" > <option value="green" <?php if($_SESSION['style'] == "green"){?> selected='selected' <?php }?> >green</option> <option value="red" <?php if($_SESSION['style'] == "red"){?> selected='selected' <?php }?> >red</option> <option value="blue" <?php if($_SESSION['style'] == "blue"){?> selected='selected' <?php }?> >bime</option> <option value="" <?php if(!isset($_SESSION['style'])){ ?> selected='selected' <?php } ?> >Select style</option> </select><br> <input type="submit" value="go"> </form> <?php echo $styles; ?> Rgds, Kris
  11. Question 1: When a user hits on the submit button, the entire form will be posted to the server regardless of the browser being closed or left open. whatever has been sent to the server side will be processed. So lets say the user pushed the submit button, and closed his browser, he just wont be seeing the success or failure or other communique in return, thats all. Question 2: By default, php script timeout is 30 secs, so if your process of a)fetching the email address. b)patching your message. c)sending doesnt fall under the 30sec mark, your script will timeout. This is a simple thing to fix, you can increase the script timeout by using set set_time_limit(x); where x = number of seconds. I usually set x to 0. which means the page will never have a time limit to complete its execution. Rgds, Kris
  12. Heres the code, the second file used here is calles test.php through which we pass the value and u can retrieve that value using GET method. <?php session_start(); $arr = array("one","two"); $_SESSION['arr'] = $arr; //count the number of items in the array; $tot = count($arr); $i = 0; while($i<$tot){ //lets send the array value to the next page for futher manipulation $url = "test.php?arrVal=".$_SESSION['arr'][$i]; header('Location: '.$url); $i++; if($i == $tot){ echo "Completed"; exit; } ?>
  13. Your problem is, on success condition, you are doing on include file, instead of a redirection. fixed: <?php session_start(); $errorMessage = ''; if (isset($_POST['txtUserId'])) { $userID = htmlentities($_POST['txtUserId']); $userPass = htmlentities($_POST['txtPassword']); //replace the following with your MySQL values //********************* $dbhost = "---"; $dbuser = "---"; $dbpass = ""; $dbname = "fleet_portal"; //********************* $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); // check if the user id and password combination exist in database $query = "SELECT * FROM company WHERE `username` = '$userID' AND `password` = '$userPass' AND `enabled`=1"; $result =mysql_query($query) or die('Query failed. ' . mysql_error()); if (mysql_num_rows($result) == 1) { // the user id and password match, // set the session $_SESSION['test_logged_in'] = true; $_SESSION['user']=$userID; // after login we move to the main page header('Location: main_login.php'); //include"main_login.php"; exit; } else $errorMessage = 'Sorry, wrong user id / password'; } if ($errorMessage != '') { ?> <p align="center"><strong><font color="#990000"><?php echo $errorMessage; ?></font></strong></p> <?php } ?> <form id="frmLogin" name="frmLogin" method="post"> <table width="400" cellspacing="2" cellpadding="2" border="0" align="center"> <tbody> <tr> <td width>User Id</td> <td><input type="text" id="txtUserId" name="txtUserId" /></td> </tr> <tr> <td width>Password</td> <td><input type="password" id="txtPassword" name="txtPassword" /></td> </tr> <tr> <td width> </td> <td><input type="submit" value="Login" name="btnLogin" /></td> </tr> </tbody> </table> </form> Rgds, Kris
  14. Hope this helps, I havent tested, but it must work perfectly. <html> <head> <style type="text/css"> <!-- .style1 { color: #000000; font-size: 14px; } --> </style> </head> <body> <form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>"> <p class="style1">Name1 : <!-- name of this text field is "name1" --> <input name="name1" type="text" id="name1" value="<?php echo $row["name1"] ?>" size="20"/> <br /> photo1 : <!-- name of this text field is "photo1" --> <input name="photo1" type="text" id="photo1" value="<? echo $row['photo1']; ?>" size="20"/> </p> <p class="style1"><?php echo $row['name1']; ?></p> <p> <span class="style1"> <input type="submit" name="Submit" value="Submit" /> </span> </p> </form> <?php if(isset($_POST['Submit'])){ $id="100"; // Alter this later // $r["id"];//take out the id $name1 = "hello"; //$_REQUEST['name1']; $photo1 = "photo"; //lets check to whether update or insert $check = "select id from test where id='$id';"; $success = mysql_query($check); $ret = mysql_num_rows($success); if($ret == 0){ // We need to insert the values. $sql = "insert into test(id,name1,photo1)values('$id','$name1','$photo1');"; }elseif($ret==1){ //update , i assume id is a primary key $sql = "update test set name1='$name1',photo1='$photo1' where id='$id';"; } $query = mysql_query($sql); if($query){ //success indicator $result = mysql_query("select * from test where id='$id'"); $row = mysql_fetch_assoc($result); }else{ echo "Query failed."; exit; } } ?> </body> </html> Rgds, Kris
  15. Operation abored with IE7 is a bug in the MS IE parser. http://support.microsoft.com/kb/927917 By having form action return to the same page has no relation with security, anybody reading you http packets will see it regardless of your <form action> being blank. So bottomline, security should be the last thing u should worry about. Kindly post your code on which you are having problems, one of us here might be able to help. Maybe its just me, but whtever code u posted didnt really help me in understanding your problem. Rgds, Krishna
  16. Heres the code that will you acheive wht you are looking for . <?php set_time_limit(0); // this will keep the script from stoping if it takes longer then 30 seconds, must have this here $dbhost = 'localhost'; //DB host $dbuser = 'root'; //DB user with read permission $dbpass = 'XXXX'; //DB password $conn = mysql_connect($dbhost,$dbuser,$dbpass) or die("Error Connecting To DB"); $dbname='test'; //db name mysql_select_db($dbname); /*assumed test database has one column(email) which is populated with email addresses. (modify per ur req) */ //get the email ids of users; $userEmails = "select distinct email from test order by email;"; $success = mysql_query($userEmails); $Total = mysql_num_rows($success); if($Total == 0){ echo "Db contains no email addresses."; exit; } //fetching the email address one after the other to send the mail while($info = mysql_fetch_array($success)){ $email = $info['email']; //we have the first users email address; $message = "Hello ".$email; $subject = "Hello "; $headers = 'From: test@test.com' . "\r\n" . 'Reply-To: test@test.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $sent = mail($email, $subject, $message, $headers); if($sent){ echo "Email sent to ".$email."<br>"; }else{ echo "Error: Unable to mail ".$email."<br>"; } } ?> Rgds, Kris
  17. Heres an example that will help you acheive this. Filename: Test.php <html><body> <form name="myform" action="" method="POST"> <input type="hidden" name="check_submit" value="1"/> First Name: <input type="text" name="name" class="buttonsb"/></p><p> You're feeling: <input type="radio" name="theme" value="grey" /> grey <input type="radio" name="theme" value="dark" /> dark <input type="radio" name="theme" value="light" /> light </p> <input type="submit" value="Process" class="buttons" onclick="return CapitalizeNames()"> </form> <?php if(isset($_POST['check_submit'])){ echo $_POST['check_submit']."<BR>"; } if(isset($_POST['name'])){ echo $_POST['name']."<BR>"; } if(isset($_POST['theme'])){ echo $_POST['theme']."<BR>"; } ?> </body></html> Rgds, Kris
  18. <?php $back = $_SERVER['HTTP_REFERER']; //contains absolute url $back = basename($back); //contains filename(eg.viewCart.php) you can manipulate this to acheive wht you want. Hope this helps. Rgds, Kris
  19. Hi Mark, The significance of the weeknumber in this case the value 5 is that I basically want the date of the 5th week on which the day is wednesday. Another example: curDate = 22/12/2008 weekDay = Friday weekNumber = 3 I would expect 19/12/2008 This is confusing, I dont knw how to go about it. Any help would be greatly appreciated. Best, Kris
  20. Hi all, I am generating a recurring instance of an .ics for outlook recurring meeting. I am stuck in a case where i need to get the next date from a week number and a weekday. for instance, curDate = 22/12/2008 weekDay = Wednesday weekNumber = 5 I need 31/12/2008 as return value. can somebody help? i think i am stuck. Rgds, Kris
  21. Your problem lies at the hidden field where you are trying to print the value of $row['id'] inside the value field. Heres a working example: Test.php (page1) ============= <html> <title>Test</title> <head></head> <body> <?php $status = "approved"; ?> <form id="test" name="test" method="post" action="collect.php"> <label> <!-- We hide the value we want to send and then post it --> <input type="hidden" name="status" value="<?php echo $status;?>" /> <input type="submit" name="button" id="button" value="Submit" /> </label> </form> </body> </html> collect.php(page2) ============== <?php include('dbconn.php'); //include db connect file $status = $_POST['status']; //$state now contains the status value, in our case it contains approved //update db $updateDB = "update table set status = '$status' where id = 100;"; $success = mysql_query($updateDB); //use an if to check if your database is updated. from here on, you can redirect the user to another page, by using php's header() function ?>
  22. Well, regardless of your browser POST retries, Its always a good idea to check for what you receive before you dump it to the database. example: $firstName= $_POST['firstname']; $find = array("'"," ","\r\n","\r"); $replace = array(" "); $firstName = str_replace($find,$replace,$firstName); ====>You spacing problem should get fixed here. Your options, update the column cell to " " or set it to null. example: SQL = "update tablename set columname = null where <condition>"; nl2br is great, but if you want your table to stay clear of html tags, its better to do strip_tags() first and write to db, and then use the wordwrap() method for rendering.
  23. Hi all, I currently use PHP's mail feature to send out emails. However now, i need to send out meeting requests(OUTLOOK). I have the names of people to whom to send. I believe outlook meeting requests are some type of headers, I cant figure. I have poured all over the web, and i couldnt find anything substantial. Can somebody here tell me how can i send meeting requests from PHP ? or point me in the right direction. Any help would be great. Best, Kris
  24. Hi all, I have a text file which i need to read line by line and fetch a certain info from that line, for example. [CISC26907] Digits are not heard properly over H.323 [CISC26928] Digits are not heard properly when G.729 codec is used . . .etc I need only the CISC26907 and CISC26928 and other such ID's contained in the file. I can read line by line, but i am unable to retrieve specific info from a line. can somebody pls help me? Rgds, kris
×
×
  • 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.