Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. [quote author=ober link=topic=99891.msg394375#msg394375 date=1152535335] I've never done any game development, but I do enjoy the work produced by those who do it :) [/quote] Me too ;D
  2. 1. Did you rename it from php_browscap.ini to browscap.ini? 2. Where did you put it?
  3. Use this: [code]<?php $filename ="mysite.com.zone"; $file = "C:\\windows\\system32\\dns\\etc\\$filename"; $fp = fopen($file, "r"); $contents = fread($fp,filesize($file)); fclose($fp); ?>[/code] or this: [code]<?php $filename ="mysite.com.zone"; $contents = file_get_contents("C:\\windows\\system32\\dns\\etc\\$filename"); ?>[/code] to get the contents of the file.
  4. Is your httpd.conf configured correct to use the PHP?
  5. [code]<?php $timestamp = mktime(0,0,1,date('m'),date('d'),date('Y')); ?>[/code] Edit: I read wrong, I thought you said before and not after.
  6. Sure, just put this in your script: [code]error_reporting(0);[/code] Or if you got access to php.ini then you may edit the display_errors setting and set it to Off.
  7. You mean kinda like the cPanel WHM permission system work?
  8. You really can't check if form data really is sent from your page. It doesn't even matter as you can change the page by sending JavaScript from the address bar, and you can tamper the data that is being sent from your page. The user will always (unless they've got some spy-/adware or a virus) be in control of the data they send in the browser.
  9. Here you go: [code]<?php // register.php //This script registers a user by storing their information in a text file and creating a directory for them. if(isset ($_POST['submit'])) //Handle form { $problem = FALSE; //No problems so far //Check for each value. if(empty($_POST['fname'])) { $problem = TRUE; print '<p>Please enter a first name!</p>'; } if(empty($_POST['lname'])) { $problem = TRUE; print '<p>Please enter a last name!</p>'; } if(!$problem) { if($fp = fopen('./users.txt', 'ab')) //Open the file { //Create the data to be written $dir = time().rand(0, 4596); $data = $_POST['fname']."\t".$data = $_POST['lname']."\t".$data = $_POST['address']."\t".$dir."\r\n"; //Write the data and close the file fwrite($fp, $data); fclose($fp); //create the directory mkdir("./users/$dir"); //Print a message print "<p>Congratulations  {$fname} {$lname}!  /></p>"; } else { //Couldn't write to the file print '<p>You could not be registered due to a system error.</p>'; } } else { //Forgot a field print '<p> Please try again!</p>'; } } else { //Display again //Leave PHP and display the form ?> <form action="register.php" method="post"> <table width="100%"  border="0">   <tr>     <th width="11%" scope="col"><div align="left"><strong>First Name: </strong></div></th>     <th width="81%" scope="col"><div align="left">       <input type="text" name = "fname" size="25" value='<?=$_POST['fname']?>' />       </div></th>     <th width="4%" scope="col">&nbsp;</th>     <th width="4%" scope="col">&nbsp;</th>   </tr>   <tr>     <td><div align="left"><strong>Last Name: </strong></div></td>     <td><div align="left">       <input type="text" name="lname" size="25" value='<?=$_POST['lname']?>' />     </div></td>     <td>&nbsp;</td>     <td>&nbsp;</td>   </tr>   <tr>     <td><div align="left"><strong>Address: </strong></div></td>     <td><div align="left">       <input type="text" name="address" size="35" value='<?=$_POST['address']?>'/>     </div></td>     <td>&nbsp;</td>     <td>&nbsp;</td>   </tr>   <tr>     <td><strong>City:</strong></td>     <td><input type="text" name="city" size="35" value='<?=$_POST['city']?>'/></td>     <td>&nbsp;</td>     <td>&nbsp;</td>   </tr> </table> <input type="submit" name="submit" value="Register" /> </form> <?php } ?>[/code]
  10. Why are you posting this in the "PHP General" forum ???
  11. This script should save a file: [code]<?php echo <<<EOF <!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> <title>File writer</title> <style type='text/css'> body { text-align: center; } body, input { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 80%; } input, textarea { border: 1px solid black; width: 100%; } textarea { font-size: 90%; font-family: "Courier New", Courier, mono-spaced; } #form { width: 500px; padding: 0px; margin: auto; text-align: left; } #form.buttonstrip { text-align: center; margin: auto; } #form label { font-weight: bold; } </style> </head> <body> <h1>File writer</h1> EOF; $dir = "/var/www/stuff/"; if(!empty($_POST['content']) && !empty($_POST['filename'])) { chdir($dir); if(file_exists($filename)) { echo "Sorry, that file already exists"; } else { $fp = fopen($_POST['filename'],'w'); fwrite($fp,$_POST['content']); fclose($fp); echo "<p>The file has been saved.<br /><a href='javascript:history.go(-1)'>Back</a></p>"; } } else { echo <<<EOF <div id='form'> <form action='{$_SERVER['REQUEST_URI']}' method='post'> <label for='filename'>Filename:</label><br /> <input type='text' name='filename' id='filename' accesskey='F' /><br /> <label for='content'>Content:</label><br /> <textarea rows='15' cols='50' name='content' id='content' accesskey='C'></textarea> <button type='submit' accesskey='S'>Save</button> <button type='reset' accesskey='R'>Reset</button> </form> </div> EOF; } echo <<<EOF </body> </html> EOF; ?>[/code] [b]Note:[/b] It is NOT secured, you need to make sure that the user won't save stuff outside of the directory if you don't trust them.
  12. Depends on if he wants the user to see the actual URL.
  13. First run this query: [code]ALTER TABLE your_table_name_here ADD UNIQUE (session_id);[/code] Then when inserting the new row, you could do something like this: [code]<?php // ... $query = @mysql_query("SELECT * FROM your_table_name_here WHERE ip_address='{$_SERVER['REMOTE_ADDR']}'"); if(@mysql_get_num_row($query) <= 0) { @mysql_query("INSERT INTO your_table_name_here (session_id,ip_address,refurl,user_agent,mktime) VALUES ('$session_id','$_SERVER['REMOTE_ADDR']','$_SERVER['USER_AGENT']',".time().")"); } // ... ?>[/code]
  14. [url=http://php.net/get_browser]get_browser[/url] is an option too. And yeah, HTTP_REFERER (and HTTP_USER_AGENT too) is [i]very[/i] easy to spoof, but there is no spoof-proof way of getting the user agent. It works in the way that the browser actually sends the information along with the request, and you can modify what it sends quite easily.
  15. [quote author=trendsetter link=topic=99947.msg394266#msg394266 date=1152509106] sorry for the invalid syntax in xml. [/quote] Doesn't matter - you are here to learn :D
  16. Try adding a submit button instead. If you need it to be that picture, use this code instead: [code]<button type='submit' style='border: 0px; padding; 0px;'><img src='images/icons/save.gif' width='19' height='19' border='0'></button>[/code]
  17. Actually, it can be a client problem too. I have tried on my localhost that an application worked in Firefox and not in Internet Explorer, it was just an application for myself, so I did bother to fix it. It's just because the entire Internet Explorer is broken.
  18. And after doing that you can delete the browscap.ini file in your directory (it's not being used).
  19. Web development, it's the only thing I'm good at. I only know a bit of C, C++, Python and Delphi, but it's far from my PHP knowledge.
  20. I would have voted both if I could, because it depends on the situation. I use cookies for storing things for long time and sessions for stuff that do not have to be saved when the user has gone away.
  21. Heh, just noticed the line saying [code]if ($_POST) { // CURLY BRACKET (Open): After Clicking Submit[/code]. $_POST is always true... you should do something like [code]if(count($_POST) > 0) {[/code] instead.
  22. Ahh, well then it makes sense.
  23. Daniel0

    Class vs. ID

    Yeah, but according to W3C all ids have to be unique in order to be valid XHTML:[quote]An "id" is a unique identifier. Each time this attribute is used in a document it must have a different value. If you are using this attribute as a hook for style sheets it may be more appropriate to use classes (which group elements) than id (which are used to identify exactly one element).[/quote] So you could just use an id attribute on things you know you will be using javascript on.
  24. You could also use [url=http://php.net/mysql_real_escape_string]mysql_real_escape_string[/url].
×
×
  • 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.