wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
Something like this: [code]<?php // check that the user has submitted the form if (isset($_POST['submit'])) { // open install_license.php $file = 'install_license.php'; $handle = fopen ($file, 'w'); $contents = "<?php\n\n\$key = \"" . $_POST['license'] . "\"\n\n?>"; // write contents to file: fwrite ($handle, $contents); // close the file fclose ($handle); // attempt to rename the file: if(!file_exists ('license.php')) { // rename install_license.php rename ($file, 'license.php'); } else { echo "Unabel to rename install_license.php as license.php already exists! Please delete license.php before continuing"; } echo "License added and file has been renamed!<br /><br />"; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <b>License Key:</b><br /> <textarea name="license" cols="20" rows="5"><?php echo (isset($_POST['license']) ? $_POST['license'] : ''); ?></textarea><br /> <input type="submit" name="submit" value="Add license" /> </form>[/code] Thats does what you want, create the file, set the variable and rename the file.
-
Run this code: [code]<?phg phpinfo (); ?>[/code] Look for a line called [b]Configuration File (php.ini) Path[/b] this will show you the location of the php.ini file. NOTE: if you're on a shared hosting account it is likely you will not be able to access the php.ini to edit it. Secoundly scroll down a bit further and find [b]register_globals[/b] both columns should state Off, if the right column is set to on then you have register_globals on and thus you cannot use superglobals. Instead you'll have to do this: [code]echo 'your ip is: ' . $REMOTE_ADDR;[/code]
-
Raconteur I dont get what you mean by it marks it owned by nobody. Why does it need to be marked as some user? I'm a little confused at the momemnt, prehaps its because I am a newb at *unix based systems. Prehaps you need to add a line called a [i]shebang line[/i] (I think thats waht it is called): [code]#!/usr/bin/php <?php // your code here ?>[/code] If not I'm not sure, I would expect there is some way to do what you want to do.
-
Wheres $mysql_link being set to?
-
Find out if a visitor has flash 8 installed?
wildteen88 replied to thehigherentity's topic in PHP Coding Help
I havnt but google has! :) -
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]If you want it to be a ternary then I believe it looks something like: $variable = ? (!isset($variable or $variable == 'string') "A" : "B";[/quote] close, it should be this: [code]$variable = (!isset($variable) or $variable == 'string') ? "A" : "B";[/code]
-
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]a) How do I convert the above statement in PHP, would: [code]CODE <?php $query = "SELECT * FROM news_table ORDER BY news_id DESC LIMIT 3"; mysql_query($query, $mysql_link); ?>[/code] work?[/quote] Yes that'll work fine! [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]b) How would I convert that query to display the Three Recent Titles, then linking it to the news story?[/quote] A bit like this [code]<?php //connect to do db here $query = "SELECT news_id, news_title FROM news_table ORDER BY news_id DESC LIMIT 3"; $result = mysql_query($query, $mysql_link); while($row = mysql_fetch_assoc($result)) { echo "<a href=\"news.php?id={$row['news_id']}\">{$row['news_title']}</a><br />"; } ?>[/code] Again in this code, change any instance of news_id, news_table and news_title to your field/table names.
-
Find out if a visitor has flash 8 installed?
wildteen88 replied to thehigherentity's topic in PHP Coding Help
I belive you can do this with javascript. You cant do it with PHP as it runs on the server. [a href=\"http://www.quirksmode.org/js/flash.html\" target=\"_blank\"]click here[/a] for a turorial on how to do so with javascript. -
Dont change the register_globals setting at all as can create a security issue. The variable I used is part of a group of variables called [a href=\"http://uk2.php.net/manual/en/language.variables.predefined.php#language.variables.superglobals\" target=\"_blank\"]super globals[/a] You only use these variables when you need to access server information, cookie, session, post'd and get data etc. I would suggest you get a book that is uptodate and doesnt use register_globals for its examples.
-
You say the user is changing the session id! If the user can change the session id then it looks like you script has a major security flaw!!
-
Umm,. just as I thought! The book is teaching you old code, well not old, but deperciated code. Try this instead: [code]<?php # This page lists some cool information for the user echo "You are running the file <b>$_SERVER['PHP_SELF']</b>.<br />\n"; echo 'You are viewing this page using: <b>', $_SERVER['HTTP_USER_AGENT'], '</b>.<br />from IP address ', $_SERVER['REMOTE_ADDR']; ?>[/code] The problem is to do with a PHP setting called [a href=\"http://uk.php.net/register_globals\" target=\"_blank\"]register_globals[/a]
-
Still need a form even if its a textarea. To autopupulate the textarea when the data is sent you can use this: [code]<td width='25%' align='left' valign='top'>Enter data:</td> <td width='75%' align='left' valign='middle'><textarea name='license' rows='3' cols='59'><?php echo ((isset($data) ? $data : ''); ?></textarea></td>[/code]
-
Find out if a visitor has flash 8 installed?
wildteen88 replied to thehigherentity's topic in PHP Coding Help
You can check whether the user has flash8 installed within flash itself. Have a look at this from [a href=\"http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_14294\" target=\"_blank\"]Adobe[/a] for play detection. -
What! You got to use a form in order to send the information to your script! How else is the information going to be sent to your script in order to be processed?
-
Are you using echo or print to output the information? Also what variables are you using to get the filename, user agent (web browser) and ip address. Also could you paste you code here, you should be able to. If you code has functions add a space before the parenthesis like so: [code]function_name ()[/code]
-
If you want to use the FTP protocol PHP has inbuilt ftp functions, [a href=\"http://uk.php.net/manual/en/ref.ftp.php\" target=\"_blank\"]click here[/a] for more imformation. Ignore the installation and requirements bit and look at the example, its about half way down the page.
-
Warning: Cannot modify header information
wildteen88 replied to DaveTomneyUK's topic in PHP Coding Help
The error is comming from meta.php on line 6 this where the output has started so look at lines 4 - 8 in meta.php Hava a read of this [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=95562\" target=\"_blank\"]thread[/a] . It'll help you understand why you are getting this error message. -
Are you having problems posting code? If you are read this [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=96050&pid=384590&st=0entry384590\" target=\"_blank\"]thread[/a]
-
I adopt both methods it depends on what I'm doing. But if I use the first method I dont echo/print line by line I do this instead: echo "<table> <tr> <td>asjsdjdj></td> </tr> </table> more html here"; Or I use HEREDOC if its large blocks of html. its not work typeing echo or print for each line of html print/echo statements can span muiltple lines so which bother echo/print'ing each line one by one.
-
Script for disable viewsource and rightclick options
wildteen88 replied to phpbaby's topic in Javascript Help
Yeah those scripts are completly useless! All I have to do is disable javascript and hay presto I can right click etc. Or I can press the menu button on the keyboard next to the right Ctrl key and I can select the view source option there! Basically dont bother with it. -
I see your problem! In your anchor tag you have an image already displayed. Now the image is overlayed ontop of you background, so your background image is not displayed as it is underneath you image. You'll be best of with javascript to swap the images over.
-
You need to upload the file instead, by creating a html form and PHP code to move the ffile to the desired location, look at this tutorial on doing so: [a href=\"http://www.developerfusion.co.uk/show/2892/\" target=\"_blank\"]http://www.developerfusion.co.uk/show/2892/[/a]
-
You'll want to use the e modify like so: $string = preg_replace('#\[star](.*?)\[/star\]#ise','<a href="blabla.php?ara='.urlencode(\\1).'" >*</a>',$string);
-
OKay can you explain in more detail what that code you posted is supposed to do and what it is currently doing. Without that information how are we supposed to know what to suggest in order to solve this problem.
-
$_SERVER['HTTP_REFERER'] That variable stores the last location the user come from.