Jump to content


  • Posts

  • Joined

  • Last visited

Executer's Achievements


Newbie (1/7)



  1. Correct code: <? function News() { if (!isset($_GET['do'])) { $local_file = 'news.nfo'; $file = fopen($local_file , 'r') or die("Couldn't open first place"); while (!(feof($file))) { $news[] = fgets($file, 1000); //Slap each line upto 1000 chars into an array } $servertime = time(); echo date("H:i:s, d M, Y", $servertime) . "rn<br>"; $numitems = count($news); echo "Count : $numitems<br>rn"; for($x=0; $x < $numitems; $x++) { echo $news[$x] . "<br>"; } echo "<a href=" . $_SERVER['PHP_SELF'] . "?do=new>Add News</a>n"; fclose($file); } elseif ($_GET['do'] == "new") { echo "<form method='post' action=" . $_SERVER['PHP_SELF'] . "?do='add'>" . "Author<br>" . // THIS WOULD BE LINE 34. '<input type="text" size="15" name="author"><br>' . "News to add :<br>n" . '<textarea rows="20" cols="60" name="new_news">' . '</textarea><br>' . '<input type="submit" name="submit" value="Add News"><br>' . '</form>'; } elseif ($_GET['do'] == "add") { $time = time(); $read_time = date("H:i:s, d M, Y", $time); $unstripped_news = $_POST['new_news']; $new_news = stripslashes($unstripped_news); $author = $_POST['author']; $fpnews = fopen('news.nfo', 'r'); $old_content = fread($fpnews, filesize('news.nfo')); $fp = fopen('news.nfo', 'w'); fwrite($fp, "rn$timern$authorrn$new_newsrn$old_content", (strlen($time) + strlen($new_news) + strlen($author) + strlen($old_content) + 16)); echo "News added successfully. Here is what you posted.<br>n" . "Submitted on $read_time<br>n" . "By : $author <br>n" . "News : <br> n$new_news <br> n"; echo "Back to <a href=" . $_SERVER['PHP_SELF'] . ">news</a>"; fclose($fpnews); fclose($fp); } echo "n<br>n<a href=" . "/news.php" . "s>View my Source!</a>"; echo "n<br>n blah blah blah <a href=news.nfo>news.nfo<a/> : " . filesize('news.nfo'); } ?>
  2. So you are trying to say that you a are building a registratation system.All you got to do is to make a form, you name each form and then you do it like this: $name = htmlspecialchars($_POST['name']); // I just named the form, and secured it.$lastname = htmlspecialchars($_POST['lastname']); // Same things here.$query = mysql_query("INSERT INTO table (name, lastname) VALUES ('$name', '$lastname')") or die("query failed : " . mysql_error()); I won't build a whole registratation system here, but this is the main idea.And if you wan't to select the news members it goes like this: mysql_query("SELECT * FROM table WHERE name AND lastname LIMIT 0, 10") or die("query failed : " . mysql_error()); But I'm not sure.
  3. I use MySQL = The most popular, and good.Before you start learning how to work with databases, make sure you are making the good the decision of picking a good database.
  4. Executer

    Login Problem

    He uses localhost, I guess his username is 'root' and he doesn't have any password.
  5. Executer

    Login Problem

    but you must to work with mysql_connect(); correctly: mysql_connect("localhost", "root", "");
  6. SELECT * FROM table WHERE name = Mike Alba; And then you print the way you want it to look like with the while loop: $query = mysql_query("SELECT * FROM table WHERE name = Mike Alba") or die("query failed : " . mysql_error());while($row = mysql_fetch_array($query)){echo $row['name'];}
  7. Executer

    Login Problem

    You are not using mysql_connect function correctly!And 1 more question: Why'd you put $_POST in (..), only if you were using any kind of security it should go like:htmlspecialchars($_POST['username']);You don't need the (..) in there.
  8. Recommandation:Use session_unset(); after the session_destory();
  9. I didn't really understand.I guess you should use:unset($_POST['form']);Let me know if I didn't understand you.
  10. I would like to join.I've already built a game with PHP+MySQL, and now I am working on another one.My PHP and SQL abilities are great.
  11. Executer

    problem in mail

    mail() function is on, they didn't turn it off.And you prob is that you didn't put [...]: <!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=iso-8859-1" /><title>Untitled Document</title></head><body><?php// mail function spamcheck($field){//eregi() performs a case insensitive regular expression matchif(eregi("to:",$field) || eregi("cc:",$field)) return TRUE;elsereturn FALSE;}$error="";if(isset($_POST['s1'])){$tfname = $_REQUEST['txtfname'];$tlname = $_REQUEST['txtlname']; $temail = $_REQUEST['txtemail'];$tptit = $_REQUEST['txtptit'];$tqual = $_REQUEST['selcou'];$tpdes = $_REQUEST['txtapdes'];$tadd = $_REQUEST['txtadd'];$tphone = $_REQUEST['txtpho'];// First Nameif (!eregi("^[(0-9a-z_)]+[(0-9a-z)]$", $tfname)){$error .= "First Name ";}// Last Nameif (!eregi("^[(0-9a-z_)]+[(0-9a-z)]$", $tlname)){$error .= "Last Name ";}/* // Qualificationif (!eregi("^[0-9a-z_]+[0-9a-z]$", $tlname)){$error .= "Qualification ";}*//* White space\s* matches 0 or more spaces\s+ matches 1 or more spaces*/// Email if (!eregi("^[a-z]+[ _\.0-9a-z_]+[0-9a-z]+@([0-9a-z][0-9a-z._]+\.)+[a-z]{2,4}$", $temail)){$error .="Email Address ";}// Project Titleif (!eregi("^[(0-9a-z_)\s*]+[(0-9a-z)]$", $tptit)) {$error .= "Project Title ";}/*// Project Desecriptionif (!eregi("^[0-9a-z]$", $tpdes)){$error .= "Project Description ";}// Addressif (!eregi("^[0-9a-z]$", $tadd)){$error .= "Address ";}*//*// Phoneif (!eregi("^[0-9]$", $tphone)){$error .= "Phone Number ";}*/if ($error == ""){// check zip or rar file type if (($_FILES["file"]["type"] == "application/x-zip-compressed") || ($_FILES["file"]["type"] == "application/octet-stream")) {if ($_FILES["file"]["error"] > 0){$error .= "Return Code: " . $_FILES["file"]["error"] . "<br />";}else{$pro='/x1x2x1x2/';$uploadDir = $pro;if($_POST){$fileName = $_FILES['file']['name'];$tmpName = $_FILES['file']['tmp_name'];$fileSize = $_FILES['file']['size'];$fileType = $_FILES['file']['type'];$filePath = $uploadDir . $fileName;echo ($filePath);// get the file extension first$ext = substr(strrchr($fileName, "."), 1); // echo ("<br>" . $ext);// make the random file name$randName = md5(rand() * time());// echo ("<br>" . $randName . "<br>");$imag=$randName.'.' . $ext;// echo ($imag);// and now we have the unique file name for the upload file$filePath = $uploadDir . $randName . '.' . $ext;// echo ("<br>File Path : ".$filePath."<br>");$result = move_uploaded_file($tmpName, $filePath);chmod($filePath,0777);// echo ("uploaded successfully <a href=".$filePath.">".$filePath."</a>");}}}//if "email" is filled out, send emailif (isset($_REQUEST['txtemail'])){//check if the email address is invalid$mailcheck = spamcheck($_REQUEST['txtemail']);if ($mailcheck==TRUE){echo "Invalid input";}else{ //send email$fname = $_REQUEST['txtfname'];$lname = $_REQUEST['txtlname'];$quali = $_REQUEST['selcou'];$email = $_REQUEST['txtemail'];$subject = $_REQUEST['txtptit'];$pdes = $_REQUEST['txtapdes'];$files = $_REQUEST['file'];$add = $_REQUEST['txtadd'];$pho = $_REQUEST['txtpho'];$filename = $_FILES['file']['name'];$headers = 'From: ' .$email ."\r\n";$headers = 'MIME-Version: 1.0' . "\r \n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n" . phpversion();//mail($to, $subject, $message, $headers);$message = '<html><body><table border=1 align=center width=700><tr><td><table border=0 align=center width=100%><tr><td colspan=2 bgcolor=#003399 align=center><font name=arial color=white size=20pt align=center>'.$subject.'</font></td></tr><tr><td>Name </td><td>'.$fname . ' '. $lname .'</td></tr><tr><td>Email</td><td>'.$email.'</td></tr><tr><td>Numbers </td><td>'.$quali.'</td></tr><tr><td>Description</td><td>'.$pdes.'</td></tr><tr><td>Attachment </td><td><a href=// http://www.example.com'.$filePath...></tr><tr><td>Address</td><td>'.$add. '<br> Phone : '.$pho.'</td></tr><tr><td colspan=2><a href="login.php">Login</a></td></tr> </table></td></tr></table></body></html>';// $message = htmlspecialchars($message1, ENT_COMPAT, 'ISO-8859-1');mail("example@example.com", $subject, $message, $headers);// echo "<br>Thank you for using our mail form";// header("location:index.html");// exit();}}}else{$error .= "Invalid ";}}?><form method='post' action='cmail.php' enctype='multipart/form-data'><table width="450" border="0" align="center" cellpadding="2" cellspacing="2" bgcolor="#FFFFFF" valign="top"><tr><td align='left' valign='top' class='lblclr'><span class='style19'>FName </span></td><td align="left" valign="top"><div align="left"><input name='txtfname' type='text' class='txtclr' id='txtfname' size='30' maxlength='50' value="<?=$_REQUEST['txtfname']?>" /></div></td></tr><tr><td align='left' valign='top' class='lblclr'><span class='style19'>LName </span></td><td align="left" valign="top"><div align="left"><input name='txtlname' type='text' class='txtclr' id='txtlname' size='30' maxlength='50' value="<?=$_REQUEST['txtlname']?>" /></div></td></tr><tr><td align='left' valign='top' class='lblclr'><span class='style19'>Numbers </span></td><td align="left" valign="top"><div align="left"><span class='style11'><select name="selcou" class='txtclr'><option selected="selected"><?=$_REQUEST['selcou']?></option><!-- <option selected=selected>Courses</option> --><option selected="selected">One</option><option>Two</option><option>Three</option></select></span></div></td></tr><tr><td align='left' valign='top' class='lblclr'><span class='style19'>Email </span></td><td align="left" valign="top"><div align="left"><input name='txtemail' type='text' class='txtclr' id='txtemail' size='30' maxlength='50' value="<?=$_REQUEST['txtemail']?>" /></div></td></tr><tr><td align='left' valign='top' class='lblclr'><span class='style19'>Text </span></td><td align="left" valign="top"><div align="left"><input name='txtptit' type='text' class='txtclr' id='txtptit' size='30' maxlength='100' value="<?=$_REQUEST['txtptit']?>" /></div></td></tr><tr><td align='left' valign="top" class='lblclr'><span class='style19'>Description </span></td><td align="left" valign="top"><div align="left"><span class='style11'><textarea name='txtapdes' cols='35' rows='5' class='txtclr'><?=$_REQUEST['txtapdes']?> </textarea></span></div></td></tr><tr><td align='left' valign='top' class='lblclr'><span class='style19'>Upload file and < 2 MB </span></td><td align="left" valign="top"><div align="left"><input name='file' type='file' class='txtclr' id='file' size='30' /></div></td></tr><tr><td align='left' valign='top' class='lblclr'><span class='style19'>Address </span></td><td align="left" valign="top"><div align="left"><input name='txtadd' type='text' class='txtclr' id='txtadd' size='30' maxlength='150' value="<?=$_REQUEST['txtadd']?>" /></div></td></tr><tr><td align='left' valign='top' class='lblclr'><span class='style19'>Phone </span></td><td align="left" valign="top"><div align="left"><input name='txtpho' type='text' class='txtclr' id='txtpho' size='30' maxlength='10' value="<?=$_REQUEST['txtpho']?>" /></div></td></tr><tr><td colspan="2"><div align='center'><span class='style1'><?=$error?></span></div></td></tr><tr><td align="center"> </td><td align="center"><div align='left'><span class='style11'><input name='s1' type='submit' class='heading' value='Submit Form'/><input name="r1" type="reset" class="heading" id="r1" value="Clear Form" /></span></div></td></tr></table></form></body></html> this is the fixed code.
  12. the syntax of the mail function should go like this: mail("url@url.com", "Web mail", $email, $subject, $message); and i don't think that you can put 2 variables in this function, you should make on variable named 'headers' which contains those 2 variables. ($email, $subject).
  13. If you are making a registratation system: <?phpsession_start();session_destory();session_unset();?> but if you are only trying to destory the session, use session_destory();
  14. If you are making a registratation system: <?phpsession_start();session_destory();session_unset();?> but if you are only trying to destory the session, use session_destory();
  • Create New...