-
Posts
3,404 -
Joined
-
Last visited
-
Days Won
55
Everything posted by Ch0cu3r
-
When inserting values into the database they should be in their rawest state. Not formatting should be applied. As you storing a date you should use a date type as field type. You can then use MySQL's Date and Time aggregate functions (or PHP's date and time functions) to format the user s DOB it into a human readable format eg convert 2002-02-08 into Feb 8th 2002
-
To prevent directory traversal. A malicious user could completely by pass your form and submit a malicious file path or value. Which could be used to attack your server by either retrieving sensitive information or run an XSS attack. Basically number one rule of thumb never trust user input. Before using it you need to verify/sanitize it before using it. With my code it ensures the file in $_POST['logo'] only exists in your /ebayimg/logos/ directory. Of course add <option></option> after the opening <select> tag
-
Because you have not added the other fields to the email body. The email body is defined by the $message variable Here you start to define the email body on the first line. But the other lines you define a bunch of strings but you haven't told PHP what to do with them $message = "Name: $fname . $lname\n"; "Email: $email\n"; "Postal Address: $paddress\n"; "Contact Number: $cnumber\n"; "Number of Bedrooms: $bedrooms\n"; "Furnished, Unfurnished or Part Furnished: $furnished . $unfurnished . $partfurnished\n"; "Which town will you be working in?: $townwork\n"; "Preferred distance from property to work (miles): $distancework\n"; "When do you need the accomodation?: $when\n"; "Maximum rental per month(£): $maximum\n"; . "Additional information: $additional\n"; You need to prepend the rest of the lines with $message .= so they are added to email body. OR change the semi-colons at end of all the lines expect the very last line one to a period
-
The problem is related to the if statement here if( isset( $_POST['user'] ) && isset( $_POST['pass'] ) && isset( $_POST['pass_again'] ) && isset( $_POST['firstname'] ) && isset( $_POST['lastname'] ) && isset( $_POST['email'] ) && isset( $_POST['email_again'] ) && isset( $_POST['address_1'] ) && isset( $_POST['address_2'] ) && isset( $_POST['town'] ) && isset( $_POST['county'] ) && isset( $_POST['postcode'] ) && isset( $_POST['business'] ) && isset( $_POST['vat_registered'] ) && isset( $_POST['vat_number'] )) { One of the $_POST variables is not set this is causing the if statement to fail and so you get the Missing Data message shown. You need to make sure you have spelt the names of your fields correctly both in your HTML code and PHP code. Also make sure all the fields you checking to see exist actually show up in the output of this line (add it before the line above) printf('<pre>$_POST %s</pre>', print_r($_POST, true));
-
Add it before the last line maybe? $sql = "SELECT * FROM t_persons WHERE PersonID>0" . $likes . " ORDER BY PersonID DESC";
-
The errors are self explanatory. You are trying to call your checkban() function which you have not been defined! You have only defined this function your admin script. PHP will not be aware of that. So you need to make that function accessible from index1.php. I would suggest moving any common used functions into a separate file and then include that file when you are going to use a common function. You have defined this function more than once. Function names must be unique. EDIT: You are getting that error because you have this code within your while loop if ($_POST["1h"]) { $mxitid1= $_POST["1h"]; if(eregi("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$", $IP_To_Add)) { $sql1 = "UPDATE ".$dbTable." SET unban_time = DATE_ADD(NOW(), INTERVAL 1 DAY) WHERE mxit_id = $mxitid1)"; $result1 = mysql_query($sq1l); } else { echo "Error: Cannot Kick: ".$IP_To_Add; } } function checkban($mxitid) { // querys database $q = mysql_query("SELECT 1 FROM ".$dbTable." WHERE unban_time > NOW() AND mxit_id = '$mxitid'",$db); $get = mysql_num_rows($q); // if found if ($get == "1") { // deny user access $r=mysql_fetch_array($q); die("You have been banned from this website until $r[legnth]. If you feel this is in error, please contact the webmaster at ."); } } Move that code so it is not within thewhile loop. For example move it so it is before this line in your admin script while ($myrow = mysql_fetch_array($result)) { You are getting that error because the regex pattern used on the line below does not match the value in $IP_To_Add if(eregi("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$", $IP_To_Add)) NOTE: You should not be using ereg*() functions they are deprecated and no longer supported. You need to convert any use of ereg*() functions to use the PCRE functions. For example if your are using eregi() you need to use preg_match() applying the i pattern modifier to the regex pattern.
-
If I understand your problem you want the user to type the name of the logo to be used. You want PHP to guess the correct image extension for the logo. I think a better idea will be to have a drop down menu populated with all your logo images. Then all you need to do is select the logo you want to use. Rather than having to type the logo name each time. Code for the dropdown <form action="extension_test2.php" method="post"> <p>Select Logo Image: <select name="logo"> <?php $logo_image_path = $_SERVER['DOCUMENT_ROOT'] . '/ebayimg/logos/'; // find all jpg,jpeg,png and gif images in the logos folder and create a item menu for each logo foreach(glob($logo_image_path.'/*.{jpg,jpeg,png,gif}', GLOB_BRACE) as $logo_image): ?> <option value="<?php echo basename($logo_image); ?>"><?php echo pathinfo($logo_image, PATHINFO_FILENAME); ?></option> <?php enforeach; ?> </select></p> <input name="Submit" type="Submit"/> </form> Then in your PHP code you'd use <?php // if the logo field has been submitted if(isset($_POST['logo'])) { // the folder where you logo images are kept $logo_images_path = '/ebayimg/logos/'; // set the path to the chosen logo image $logo_image = $logo_images_path . basename($_POST['logo']); // check if the logo exists if(file_exists($_SERVER['DOCUMENT_ROOT'] . $logo_image)) { // show the image echo '<img src="$logo_image" />'; } } ?>
-
Then rewrite the code so it does not depend on register globals. NOTE: Also please wrap code within code tags tags when posting code. For now I have edited your post.
-
[PHP, HTML, Apache (XAMP)] Inline PHP Tags Do Not Get Processed
Ch0cu3r replied to glassfish's topic in PHP Coding Help
Click the button at the bottom right hand corner of the post -
The changes you made will have no effect because the form in your admin script is not being submitted to your ip-ban-time-limit.php script! The changes you need to make to both scripts will be In the admin script, when the ban form is submitted you need to an add a new entry containing the following information into the ip-log.txt file the users ip address and the timestamp for when the ban will be lifted. For example if the user is band for 1 hour use strtotime('+1 hour') to generate the timestamp for when the ban is lifted. See strtotime for more info The ip-ban-time-limit.php script will need to be written from scratch. The steps you need to take here are get the user ip check to see if the ip is listed in ip-log.txt if it is found in the file. Check to see if the current time is greater than the recorded timestamp restrict access if sufficient time has not passed. only when sufficient time has passed you can remove the users ip from ip-log.txt
-
[PHP, HTML, Apache (XAMP)] Inline PHP Tags Do Not Get Processed
Ch0cu3r replied to glassfish's topic in PHP Coding Help
What? You saying the code used in that video does not work for you? Instead you see the PHP code? Can you tells us Where are you saving the php files to How are you accessing the php files in your browser? Ensured XAMPP is running -
locked you already have a thread here
-
The problem with your code is you have not told it who to ban. It just blindly records every visitors ip and does not allow them to access the page again until 36 seconds have passed. You need to alter the code so it only blocks the visitors who you want to ban.
-
[PHP, HTML, Apache (XAMP)] Inline PHP Tags Do Not Get Processed
Ch0cu3r replied to glassfish's topic in PHP Coding Help
XAMPP comes with everything preconfigured so there should not be any issues with running your PHP code. I think the problem is you have loaded your .php file directly into the browser (ie the address bar starts with file://) This is not how you run your PHP files. You need to first check you have saved your php files in XAMPP's htdocs folder (I assume for windows its C:/XAMPP/htdocs ) now run your php files by accessing http://localhost/yourfile.php -
What do you mean by that? Can you explain what it is you are trying to do Also when you post code please wrap it within tags next time
-
Close change 1-9 to 0-9 NOTE: You could also substitute [0-9]+ with just \d+
-
Try removing the semi-colon on this line if (!file_exists("uploads/$fuser/$create"));
-
A quick example (requires simple_html_dom.php found here) <?php // include simple_html_dom require_once 'simple_html_dom.php'; // function scraps data from $url and returns data defined in $elements function findPlayerInfoByElements($url, $elements = array()) { // load page into simpleHtmlDom $html = file_get_html($url); // get the data alias keys. This will be used as the keys to associative array return by the function $aliases = array_keys($elements); // for each element $data = array(); foreach($elements as $element) { // find all data by element $columnDataFound = $html->find($element); // if the element was found if($columnDataFound) { // return the value of the element as plain text - removes any HTML $data[] = array_map(function($v) { return trim($v->plaintext); }, $columnDataFound); } } // format the players array $players = array(); // looping over the data add each players info into seperate associative arrays for ($i = 0; $i < count($data[0]); $i++) { $info = array(); foreach($aliases as $k => $alias) $info[$alias] = $data[$k][$i]; $players[] = $info; } // unset the orginal data unset($data); // return the players info return $players; } // url to scrap roster info from $roster_url = 'http://www.seahawks.com/team/roster.html'; /* Provide findPlayerInfoByElements() function - url to scrap roster table - provide an array of elements to get data required, eg jersey no, player name, hieght and weight */ $elements = array( 'no' => 'td.col-jersey', // gets the jersey numbers from the <td> element with the class of col-jersey 'name' => 'td.col-name', // gets the players name from the <td> element with the class of col-name 'height' => 'td.col-height', // their height from the <td> element with the class of col-height 'weight' => 'td.col-weight', // their weight from the <td> element with the class of col-weight ); // returns each players info in an associative array $players = findPlayerInfoByElements($roster_url, $elements); printf('<pre>%s</pre>', print_r($players, true)); Change $roster_url will your schools roster page Modify $elements array with the HTML elements you need to find the data from. $players will contain info for each player in the roster.
-
You may be better of scrapping the data you require using DOM (or alternatively using simple_html_dom). That way you can load the roaster webpage into the above libraries and target the specific HTML elements in the HTML document and extract the data you require.
-
To me this does not appear to be a PHP problem at all but a problem with loading the page resources (such as stylesheets and images etc). Which suggests you may have not placed these files in their correct places. If open your browsers console (F12) and click on the console tab. And load your webpage. You should see errors about the resources it cannot load. From the errors check that the urls are correct for these resources You should also consult your themes documentation for how to install and use.
-
How are you using HTML Purifier for getting the jersey numbers?
-
Umm.. I think you have used return by mistake. Change return on the last two lines to echo or print.
-
I think you are confusing PHP and javascript as the same language. PHP and Javascript are completely different languages. They are both ran a completely different times. This is because PHP is a server side language, meaning it is ran on the server. The PHP code is parsed when a request for a .php file is made to the server. Any other code such as HTML/CSS/Javascript used within the PHP code will be ignored. Languages such as HTML/CSS/Javascript are client side, meaning they are parsed by the the web browser client (eg Internet Explorer, Firefox, Chrome etc). The browser parses the HTML/CSS/Javascript that is returned by the the server (eg the output from a PHP script).