Jump to content

Lulzim

Members
  • Posts

    295
  • Joined

  • Last visited

Everything posted by Lulzim

  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.
  16. Lulzim

    Forms

    to change the values on the second select box using php you should submit the data to a php script, not with mailto:also you forgot to put the submit button here is how it works:first select the computer and click 'select speed' buttonthen choose other parts and click 'submit order' button <!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>CompuDeal</title> </head> <body> <h1>CompuDeal</h1> <p />Welcome to CompuDeal! Please fill out the form below to order a computer product. Our form is simple and fool proof to use. <form <? if ($_POST["selectbox1"] != "") echo "action='mailto:martin.vanputten@gmail.com'"; else echo "action='".$_SERVER['PHP_SELF']."'"; ?> method='POST'> <p />Computer: <select name="selectbox1" id="selectbox1" onchange="document.getElementById('selectbox2').selectedIndex='0'"> <option value='c1'>PC</option> <option value='c2'>Notebook</option> <option value='c3'>Workstation</option> </select> <p />Speed: <select name='selectbox2' id='selectbox2'> <?php $a188 = 'AMD Athlon 1.88GHz'; $a200 = 'AMD Athlon 2.00GHz'; $t220 = 'AMD Turion 2.20GHz'; $o188 = 'AMD Opteron 1.88GHz'; $o200 = 'AMD Opteron 2.00GHz'; if(isset($_POST["selectbox1"])) { echo "<option value=''>Speed:</option>"; switch ($_POST["selectbox1"]) { case 'c1': echo "<option value='c1speed1'>", $a188, "</option>"; echo "<option value='c1speed2'>", $a200, "</option>"; echo "<option value='c1speed3'>", $t220, "</option>"; break; case 'c2': echo "<option value='c2speed1'>", $t220, "</option>"; echo "<option value='c2speed2'>", $o188, "</option>"; echo "<option value='c2speed3'>", $o200, "</option>"; break; case 'c3': echo "<option value='c3speed1'>", $t220, "</option>"; echo "<option value='c3speed2'>", $t220, "</option>"; echo "<option value='c3speed3'>", $t220, "</option>"; break; } } ?> </select> <p />Memory: <select name='memory'>"; <option value='m1'>512MB</option> <option value='m2'>1GB</option> <option value='m3'>2GB</option> </select> <p />Space: <select name='space'> <option value='h1'>80GB</option> <option value='h2'>160GB</option> <option value='h3'>320GB</option> </select> <p>All computers are fully loaded and have NVIDIA 7900 GS 256MB graphic cards.</p> <input type='submit' value='<? if(!isset($_POST["selectbox1"])) echo "Select speed"; else echo "Submit order"; ?>'> </form> </body></html>
  17. Lulzim

    Forms

    it works fine here :Ssecond select box doesn't have any options in it, but this code below creates new options inside second <select> based on the value selected in selectbox1for (var i = 0; i < speeds[selection].length; i++){var opt = new Option(speeds[selection][i],speeds[selection][i]);speed[speed.length] = opt;}
  18. same question have been asked beforehttp://w3schools.invisionzone.com/index.ph...ic=7583&hl=http://w3schools.invisionzone.com/index.ph...amp;#entry60604the first one is with ajax
  19. Lulzim

    Forms

    a <select> cannot contain another <select>, they can contain only <option>and in every form, there should be something to click in order to submit the data, usually a submit buttonhere is a good tutorial for html forms http://www.w3schools.com/html/html_forms.asphere is the same script, but this time with javascript <!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>CompuDeal</title> <script type='text/javascript'> var speeds = new Array(); speeds[0] = new Array ("AMD Athlon 1.88GHz", "AMD Athlon 2.00GHz", "AMD Turion 2.20GHz") speeds[1] = new Array ("AMD Turion 2.20GHz", "AMD Opteron 1.88GHz", "AMD Opteron 2.00GHz") speeds[2] = new Array ("AMD Turion 2.20GHz", "AMD Turion 2.20GHz", "AMD Turion 2.20GHz") function change(selection) { var speed = document.getElementById("computerspeed"); speed.length = 0; for (var i = 0 ; i < speeds[selection].length ; i++) { var opt = new Option(speeds[selection][i],speeds[selection][i]); speed[speed.length] = opt; } } </script> </head> <body onload="change(0);"> <h1>CompuDeal</h1> <p />Welcome to CompuDeal! Please fill out the form below to order a computer product. Our form is simple and fool proof to use. <form action='mailto:martin.vanputten@gmail.com' method='POST'> <p />Computer: <select name="computer" id="computer" onchange="change(this.selectedIndex);"> <option value='PC'>PC</option> <option value='Notebook'>Notebook</option> <option value='Workstation'>Workstation</option> </select> <p />Speed: <select name='computerspeed' id='computerspeed'> </select> <select name='memory'> <option value='512MB'>512MB</option> <option value='1GB'>1GB</option> <option value='5GB'>2GB</option> </select> <p />Space: <select name='space'> <option value='80'>80GB</option> <option value='160'>160GB</option> <option value='320'>320GB</option> </select> <p />All computers are fully loaded and have NVIDIA 7900 GS 256MB graphic cards. </select><br> <input type='submit' value='Submit' > </form> </body></html>
  20. Lulzim

    Changing banners

    here is one way to do that:save your images with names :image1.jpgimage2.jpg....image10.jpgthan add this <?$number = rand (1,10);echo "<img src='images/image".$number.".jpg' >";?> each time the page is reloaded a random image will be displayed
  21. Lulzim

    Forms

    It is better to do this using javascript, because values in second select box change without reloading the page.Since you requested in php forum, here is an example in php. <html><body><form action='' method='get'>Computer: <select name='selectbox1' id='selectbox1' onchange="document.getElementById('selectbox2').selectedIndex='0';"><option value='c1'>Computer 1</option><option value='c2'>Computer 2</option><option value='c3'>Computer 3</option></select> Speed: <select name='selectbox2' id='selectbox2'><?if (isset($_GET["selectbox1"])){ echo "<option value=''>Select speed</option>"; switch ($_GET["selectbox1"]) { case 'c1': echo "<option value='c1speed1'>C1 S1</option>"; echo "<option value='c1speed2'>C1 S2</option>"; echo "<option value='c1speed3'>C1 S3</option>"; break; case 'c2': echo "<option value='c2speed1'>C2 S1</option>"; echo "<option value='c2speed2'>C2 S2</option>"; echo "<option value='c2speed3'>C2 S3</option>"; break; case 'c3': echo "<option value='c3speed1'>C3 S1</option>"; echo "<option value='c3speed2'>C3 S2</option>"; echo "<option value='c3speed3'>C3 S3</option>"; break; }}?></select> <input type='submit' value='submit' ></form><br><?if (isset($_GET["selectbox1"]) && isset($_GET["selectbox2"]) && $_GET["selectbox2"]!=""){ echo "Computer: ".$_GET["selectbox1"]."<br>"; echo "Speed: ".$_GET["selectbox2"];}?></body></html>
  22. Lulzim

      Question

    http://en.wikipedia.org/wiki/NBSPfirst result from Google search
  23. Lulzim

    IP address help

    here in university we have a router/gateway which has a public ip address and the internet is shared to usersthe router's ip is 85.30.65.119, my ip on my computer is 10.4.6.176when i communicate with computers in my network I am 10.4.6.176, but when I browse the web I'm 85.30.65.119it is impossible (as far as I know) to get the ip address of a computer on an internal network
  24. something like this? <html><head><script type='text/javascript'>function resize(size){ document.getElementById("txt").rows+=size;}</script></head><body><textarea id='txt' name='txt' cols='30' rows='10'></textarea> <br><input type='button' onclick='resize(1);' value='+' ><input type='button' onclick='resize(-1);' value='-' ></body></html>
  25. add this line to css area{ cursor: url('path_to_cursor_file'), default; } <!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>chotaGolf</title><style type="text/css"><!--body {margin-top: 0px;margin-bottom: 0px;margin-left: 0px;margin-right: 0px;}area{cursor: url('path_to_cursor_file'), default;}--></style></head><body><div align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><div align="center"><img src="asd.jpg" width="1024" height="566" border="0" usemap="#Map" /></div></td></tr></table></div><map name="Map" id="Map"><area shape="rect" coords="273,172,344,191" href="about_golf.html" /><area shape="rect" coords="433,170,450,191" href="index_01.html" /></map></body></html> don't forget to replace path_to_cursor_file with the file name you want to use
×
×
  • Create New...