Jump to content

dstar101

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Everything posted by dstar101

  1. Do not worry about it ;) lols elseif($state =! 1){ I thought it meant if state is not equal to one
  2. $synopsis = substr($row['story'],0,50) .'..<a href="/my-page-to-display-news.php">Read More</a>'; Thanks this code gets the work done never thought it was so simple I still want to format the text retrieved from the database using BBcodes (like one use in forums). And How can I filter PHP and Html Tags before entering the Text into Database
  3. I use this method for the following Database CREATE TABLE logins ( id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, email VARCHAR(55) NOT NULL, username VARCHAR(16) NOT NULL, pswd CHAR(32) NOT NULL, hash CHAR(32) NOT NULL, PRIMARY KEY(id)); hope it helps <?php // Create unique identifier $id = md5(uniqid(rand(),1)); // User's email address $address = $_POST[email]; // Set user's hash field to a unique id $query = "UPDATE logins SET hash='$id' WHERE email='$address'"; $result = mysql_query($query); $email = <<< email Dear user, Click on the following link to reset your password: http://www.example.com/users/lostpassword.php?id=$id email; // Email user password reset options mail($address,"Password recovery","$email","FROM:services@example.com"); echo "<p>Instructions regarding resetting your password have been sent to $address</p>"; ?> <?php // Create a pseudorandom password five characters in length $pswd = substr(md5(uniqid(rand())),5); // User's hash value $id = $_GET[id]; // Update the user table with the new password $query = "UPDATE logins SET pswd='$pswd' WHERE hash='$id'"; $result = mysql_query($query); // Display the new password echo "<p>Your password has been reset to $pswd.</p>"; ?>
  4. How do I add Text Formating to the Data retrieved from the Database and How do I limit the text retrieved from the DB I mean I want to Display Only 900Kbytes of text and Display link if user want to read more Here is my code: <?php session_start(); $state = $_SESSION['auth_state']; $login = ''; if($state == 1){ $login = '<a href="../login/logout.php">Logout</a>'; } elseif($state =! 1){ $login = '<a href="../login/login.php">Login</a>'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Full Story</title> <link href="../_css.css" rel="stylesheet" type="text/css" /> </head> <?php require("../connectvars.php"); ?> <?php $author = $_GET['author']; $id = $_GET['id']; if(!empty($author) AND !empty($id)){ $query = "SELECT * FROM info WHERE author='{$author}' AND id={$id} ;"; $cxn = mysql_connect(server, user, pass) or die("USer or password incorrect"); mysql_select_db("books") or die ("DB books not found"); $res = mysql_query($query,$cxn)or die ("Query Failed"); while($row = mysql_fetch_array($res)){ $author = $row['author']; $synopsis = $row['story']; $article = $row['reading']; $title = $row['title']; } ?> <body> <table border="0" align="center"> <tr> <td class="nav">Author:<?php echo $author ; ?></td> <td class="dingbat">Title: <?php echo $title ; ?></td> </tr> <tr> <td><a href="../index.php">Main</a></td> <td class="nav">Summary<?php echo $synopsis ; ?></td> </tr> <tr> <td><?php echo $login; ?></td> <td class="sidebarHeader"><?php echo $article; ?></td> </tr> </table> <?php } else{ echo "Either ID or Author is Not Specified"; } ?> </body> </html>
  5. Oops sorry I mistyped it is mysql_connect(ADD,USER,PASS);
  6. $newdb = mysql_connect_db(ADD, User, pass); mysql_select_db(dbname, $newdb);
  7. You can not store images in Database. First You need to create a new folder in your site root to store images.Then save the image name in Database and to display the image use the file name from DB example: define('GW_UPLOADPATH', 'images/'); fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $target = GW_UPLOADPATH . $tmpName; move_uploaded_file($_FILES['userfile']['tmp_name'], $target $conn = mysql_connect("localhost", "root", ""); mysql_select_db("test", $conn); $query = "INSERT INTO pics VALUES ('','$fileName', '$fileType', '$fileSize')"; mysql_query($query, $conn) or die('Error, query failed'); echo "<br>File $fileName uploaded<br>"; } ?>
  8. I would suggest you using SHA for hashing password. SHA can not be decrypt because it is one way only.Instead of decrypting SHA you need to compare it And it works good for password protecting site.MySQL also comes with SHA(),MD5() and other fucntions
  9. Add the code in new file and use require_once to access them.You still need to use global statement
  10. It's not simple to implement :-\ :-\ Many CMS usese mod_rewrite to achieve this goal....look into mod_rewrite
  11. $dbh = mysqli_connect($db_host,$db_user,$db_pass,$db_name); If mysqli extensions are not supported $cxn = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db(db_name, $cxn);
  12. Thanks my problem is solved
  13. Thanks for the quick reply.. My Question is How to write scripts which do not require global_variables to be turn ON as the PHP sites says that it is deprecated in new versions
  14. Hi! I am new to PHP and I am still learning. In PHP when I tried to create File Uploading Script, at first it was not working but when I enabled "register_globals = ON" It is now working but in php.ini it says So My question is How I can write my script with out using globals register
×
×
  • 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.