Jump to content

Lulzim

Members
  • Posts

    295
  • Joined

  • Last visited

About Lulzim

  • Birthday March 1

Contact Methods

  • Website URL
    http://
  • ICQ
    0

Profile Information

  • Location
    Kosovo
  • Interests
    Web Programming

Lulzim's Achievements

Member

Member (2/7)

3

Reputation

  1. even though your user has no password you have to specify the user. mysqldump -u root database_name > e:/sql/alpha2.sql try running the command on command line first to see if you get the desired result and then put int on php script and if you are on windows, you might have to include the full path to mysqldump (something like "c:program filesmysqlbinmysqldump.exe -u root database_name > e:/sql/alpha2.sql")
  2. Lulzim

    Need Help Here..

    You just had to make a few small changes: <?php$dateFromDb = new DateTime($replace_this_with_your_date_from_db); #don't forget to fix this line$currentDate = new DateTime();$difference = $currentDate->diff($dateFromDb);if($difference->m>=1){ echo "1 month has passed please register.";}else { echo "Carry on"; }
  3. Lulzim

    Need Help Here..

    Something like this? $dateFromDb = new DateTime('2013-08-16 10:55:14');$currentDate = new DateTime();$difference = $currentDate->diff($dateFromDb);if($difference->m>=1){ echo "years: ".$difference->y."<br />"; echo "months: ".$difference->m."<br />"; echo "days: ".$difference->d."<br />"; echo "hours: ".$difference->h."<br />"; echo "minutes: ".$difference->i."<br />"; echo "seconds: ".$difference->s."<br />";}
  4. Get the required information from a form, then generate php code and save it to a file. Something like this in your case: <?php$string = '<?php $db_host = "'. $_POST["db_host"]. '";$db_uname = "'. $_POST["db_uname"]. '";$db_pass = "'. $_POST["db_pass"]. '";$db_name = "'. $_POST["db_name"]. '";?>';$file = fopen("config.php", "w");fwrite($file, $string);fclose($file);?>
  5. The difference Include_once and include (same as require_once and require) is that *_once will check if the file was included/required before, it will not include it again. And the difference between include and require is that require will stop the execution of the script if it cannot find the file required and generate a fatal error. While include will only issue a warning and continue the execution of the script. So for essential code, as in this case DB connection, require_once is best.
  6. Yeah, try to look at error_log if you don't set display errors as thescientist suggested. Here are a few errors you have: Notice: Undefined variable: nameپست in ... Meaning if you are going to put a variable inside a string, concatenate it or enclose on {}Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in ... The email you typed "info@keivanstone.ir <>" is not a vaild email. Remove <> or format it properly. Also, change this line $_SESSION['captcha'] = $num . $num2; to $_SESSION['captcha'] = $num+$num2; because it is very confusing. Look at the code I posted above, I have fixed all these errors :S
  7. Just FYI, the way you are constructing the query is very dangerous. Read through this page so you can see what can happen and how to protect it http://php.net/manual/en/security.database.sql-injection.php
  8. I tested your script and here is what I found: -You need to use session_start() if you are going to use sessions. That is why $captcha != $_SESSION['captcha'] will always fail. -About the captcha, did you mean to add the two numbers and enter the result on the text box, or just concatenate them? Because as it is right now, if you add them, lets say you get 24 + 10 and you enter 34 it will not work. As it is right now, for that example you should write 2410. Here is the complete code that worked for me <?phpsession_start(); #was missingini_set("display_errors",1); #remove this on production, needed it to see any errors$php_self = $_SERVER['PHP_SELF'];//$error_name = " you don't enter name.please enter you name.";// on submit$mail_sent=0;$error_name = $error_email = $error_subject=$error_body = $error_captcha = '';if( isset($_POST['name']) && isset($_POST['email'])&&isset($_POST['subject']) && isset($_POST['body']) && isset($_POST['captcha']) ){ $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $body = $_POST['body']; $captcha = $_POST['captcha']; $error = 0; // name if( $name == "" ){ $error=1; $error_name = "class='error'"; } // email if( $email == "" ){ $error=2; $error_email = "class='error'"; } // subject if( $subject == "" ){ $error=3; $error_subject = "class='error'"; } // body if( $body == "" ){ $error=4; $error_body = "class='error'"; } // captcha if( $captcha == "" || $captcha != $_SESSION['captcha']){ $error=5; $error_captcha = "class='error'"; } // no error, send email if( $error == 0){ // your email address $address = "info@keivanstone.ir"; // email subject $subject = "New body"; // email content $content = "نام:$nameپست الکترونیک:پیام شما:$email$body"; // html email $email_content = "<!doctype html><head><meta charset='utf-8'><title>".$subject."</title>"; $email_content .= "</head><body>"; $email_content .= $content; $email_content .= "</body></html>"; // headers for html email $headers = 'MIME-Version: 1.0' . "/r/n"; $headers .= 'Content-type: text/html; charset=utf-8' . "/r/n"; $headers .= "From: info@keivanstone.ir" . "/r/n"; // send email mail($address, $subject, $email_content, $headers); // reset variables $name = ""; $email = ""; $body = ""; $mail_sent = 1; }}else{ $name = $email = $subject= $body = $captcha = ''; }// captcha$num = rand(1, 40);$num2 = rand(5, 25); $verif = $num . "+" . $num2;$_SESSION['captcha'] = $num . $num2; if( $mail_sent == 1 ){ echo "<h1>از تماس شما سپاسگزاریم.تا48 ساعت آینده پاسخ خود را دریافت خواهید کرد.<br/>گروه سنگ آنتیک کیوان</h1>";} else { echo " <form action='".$php_self."' method='post'> <p><label for='name'>نام:</label> <span class='required'>*</span></p> <input type='text' ".$error_name." name='name' value='".$name."'> <p><lable for='email'>پست الکترونیک:</label> <span class='required'>*</span></p> <input type='text' ".$error_email." name='email' value='".$email."'> <p><label for='subject'>موضوع:</label> <span class='required'>*</span></p> <input type='text' ".$error_subject." name='subject' value='".$subject."'> <p><label for='body'>پیام شما:</label> <span class='required'>*</span></p> <textarea ".$error_body." id='body' name='body' style='width:460px;height:119px;'>".$body."</textarea> <p><label>جمع دوعدد:".$verif."?</label> <span class='required'>*</span></p> <input type='text' ".$error_captcha." id='captcha' name='captcha' value=''><br/> <input type='submit' value='ارسال'/> </form>";}?>
  9. hmmm, you must have any problem with your server than, it works fine heretry is_int() or is_integer() instead of ctype_digit
  10. this is what i changed: if($miles == "" || $numberOfStops == "" || !ctype_digit($miles) || !ctype_digit($numberOfStops)) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Passenger Train</title> </head> <body> <form action="PassengerTrain.php" method="post"> <?php $numberOfStops = $_POST["numberOfStops"]; $speed = 50; $weatherDecrease = 40; $stop = (60 - $numberOfStops) * 5; $miles = ($_POST['miles']); $numberOfStops = $_POST['numberOfStops']; if(isset($_POST['submit'])) { if($miles == "" || $numberOfStops == "" || !ctype_digit($miles) || !ctype_digit($numberOfStops)) echo "<p />Please fill in your information appropriately."; else { if($_POST['weather'] == '1') $result = $stop * $miles / $speed; else if($_POST['weather'] == '2') $result = $stop * $miles / $weatherDecrease; } } echo "<p />Miles:<input type='text' name='miles' value='' size='1' maxlength='3' />"; echo "<p />Number of stops:<input type='text' name='numberOfStops' value='' size='1' maxlength='3' />"; echo "<p />Good weather:<input type='radio' name='weather' value='1' checked='checked' />"; echo "<p />Bad weather:<input type='radio' name='weather' value='2' />"; echo "<input type='submit' value='OK' name='submit' />"; echo $result; ?> </form> </body></html>
  11. if(isset($_POST['weather']) == '1')$result = $stop * $miles / $speed;else if(isset($_POST['weather']) == '2')$result = $stop * $miles / $weatherDecrease; in this case isset($_POST['weather']) returns true , you actualy are checking if (true=='1')so it should be if($_POST['weather'] == '1')$result = $stop * $miles / $speed;else if($_POST['weather'] == '2')$result = $stop * $miles / $weatherDecrease; also variable $numberOfStops is empty, use $_POST["numberOfStops"] instead
  12. I think there is a problem with the quotesyou should use " " or ' ' instead of ”” and ’’also the textarea should have an id by which you can use getElementByIdhere is an example <html><body><textarea id='test'>aksjdhkajhdjkas</textarea><br><input type='button' onclick="document.getElementById('test').value='';" value='clear'></body></html>
  13. in order to help you show us some code or any error that you get, otherwise how do we know why it's not working
  14. document.title="new title" but here says 'returns the value' not 'sets or returns'
  15. Lulzim

    Pop ups in PHP?

    What do you mean by that? To use php as a replacement of javascript to open pop-ups? If so then the answer is no. You can use javascript to open pop-ups and display content form a php script.
×
×
  • Create New...