Daniel0
Staff Alumni-
Posts
11,885 -
Joined
-
Last visited
Everything posted by Daniel0
-
[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
-
1. Did you rename it from php_browscap.ini to browscap.ini? 2. Where did you put it?
-
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.
-
php not working now.... IE wants to DL .php files.
Daniel0 replied to just-j's topic in PHP Coding Help
Is your httpd.conf configured correct to use the PHP? -
[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.
-
Is there a way to stop php from writing an error message to the screen?
Daniel0 replied to bobleny's topic in PHP Coding Help
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. -
You mean kinda like the cPanel WHM permission system work?
-
Ensuring pages are submitted by my page not another location
Daniel0 replied to Chips's topic in PHP Coding Help
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. -
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"> </th> <th width="4%" scope="col"> </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> </td> <td> </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> </td> <td> </td> </tr> <tr> <td><strong>City:</strong></td> <td><input type="text" name="city" size="35" value='<?=$_POST['city']?>'/></td> <td> </td> <td> </td> </tr> </table> <input type="submit" name="submit" value="Register" /> </form> <?php } ?>[/code]
-
Why are you posting this in the "PHP General" forum ???
-
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.
-
Depends on if he wants the user to see the actual URL.
-
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]
-
[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.
-
create a XML file of list of files in a directory
Daniel0 replied to trendsetter's topic in PHP Coding Help
[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 -
$FILES[$fv]['name'] is empty but NOT $FILES[$fv]['tmp_name']
Daniel0 replied to whisperstream's topic in PHP Coding Help
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] -
My very first php - guess what it doesnt work
Daniel0 replied to glenn kilpatrick's topic in PHP Coding Help
It works for me... -
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.
-
And after doing that you can delete the browscap.ini file in your directory (it's not being used).
-
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.
-
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.
-
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.
-
Ahh, well then it makes sense.
-
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.
-
You could also use [url=http://php.net/mysql_real_escape_string]mysql_real_escape_string[/url].