-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
no no, put this in PMA SELECT * FROM members WHERE emailaddress='$emailaddress' replace $emailaddress with a real email (from the database) could you also post the mysql_connect.inc.php script (replace private date with ##'s)
-
echo the query from the php script.. copy and paste it into a query in phpmyadmin.. if this works.. check the selected table (check it twice.. it a common place of error) along with user access right.. if it fails then check the table fields and records
-
Session is stored on the server side Cookie is stored on the client side see setcookie in the manual
-
check your database setup on the online side.. database name, records, username password etc
-
this is an encoding issule, use UTF-8, this may help http://www.w3.org/International/questions/qa-htaccess-charset
-
Yes.. but i am guessing the problem is because of them.. they cause lots of problems.. Just an idea.. change $_SESSION['id'] to $_SESSION['UserLoginID'] everywhere make a backup first now i assume you don't use UserLoginID anywhere BUT: don't set UserLoginID an ANYTHING else ie no $UserLoginID no $_COOKE['UserLoginID'] no form post values etc
-
search your project for $_SESSION['id'] = , thats where the problem is more likely to be.. also are Register Globals off ? <-- i am guessing their on
-
How can i prevent users from typing in the url???
MadTechie replied to Piba's topic in PHP Coding Help
Hi MadTechie.. Thanks for replying, but can you give me an example for that?? Quick example, <?php session_start(); $key = rand(1000,99999); $_SESSION['access'] = $key; echo "<a href=\"page2.php?access=$key\">link</a>"; ?> <?php session_start(); if($_GET['access'] != $_SESSION['access']) { echo "No Access"; exit; } session_destroy(); ?> welcome if you goto direct to page2.php it will say no access, if you click the link on page1.php it will goto page2.php and say welcome .. but if you refresh page2.php it will fail again. you can change this depends on the need of course with a login system your check the access right but for a page with a link, EDIT: as for injection read redbullmarky's post.. -
[SOLVED] Server upgrade, php Problems?
MadTechie replied to emediastudios's topic in PHP Coding Help
check the table name mysql_select_db("gcpropery");<-- is this correct ? (double check) check via phpmyadmin also is the user account setup correctly check privileges -
[SOLVED] Server upgrade, php Problems?
MadTechie replied to emediastudios's topic in PHP Coding Help
you haven't selected a database on the left then! -
[SOLVED] Beginner question regarding arrays
MadTechie replied to TonyYayo's topic in PHP Coding Help
if your reading in line by line from a text file you could do something like this <?php $newArray = array(); $handle = fopen("IP.txt", "r"); if ($handle) { while (!feof($handle)) { $e = fgets($handle); //Readline $e = trim($e); //clear and spaces //Check its a valid IP (the whole sring) if (preg_match('/^(??:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/', $e)) { if(array_key_exists($e, $newArray)) { $newArray[$e]++; }else{ $newArray[$e] = 1; } } } fclose($handle); } foreach($newArray as $C => $Names) { echo "$Names = $C times<br>"; } ?> I added a RegEx for checking valid IP's (you may wany to remove it) -
[SOLVED] Server upgrade, php Problems?
MadTechie replied to emediastudios's topic in PHP Coding Help
is this "cPanel"..? upgraded from what version to what version ? insert SQL records ? via ? phpmyadmin ? version ? -
How can i prevent users from typing in the url???
MadTechie replied to Piba's topic in PHP Coding Help
You can't stop them typing.. i think you want to stop them accessing a URL directly.. maybe use sessions (set on one page and check its set on the next) -
[SOLVED] Beginner question regarding arrays
MadTechie replied to TonyYayo's topic in PHP Coding Help
may i be the first to say welcome to the phpfreak forum as for your problem i would do something like this.. <?php $theArray = array("bob", "John", "bob", "Tim", "Bob", "John"); $newArray = array(); sort($theArray); //Not need in this code (but you said about sorting) $last=""; foreach($theArray as $e) { #$e = strtolower($e); // uncomment to ignore case if(array_key_exists($e, $newArray)) { $newArray[$e] = $newArray[$e] + 1; //Note you can also do $newArray[$e]++ }else{ $newArray[$e] = 1; } } foreach($newArray as $C => $Names) { echo "$Names = $C times<br>"; } ?> Note that theirs bob an Bob, which will count as 2 different elements unless you remove the # from this line #$e = strtolower($e); // uncomment to ignore case of course your need to format this for a table.. EDIT: added comments -
i guess you could do this $name = "John Doe"; $name = preg_replace('/(\w)\w+\s(\w+)/', '\1\2', $name );
-
[SOLVED] Online - Offline server status FORM
MadTechie replied to FireDrake's topic in PHP Coding Help
try this <html> <head> <title> RuneScape World Stutus </title> </head> <body bgcolor=black text=white> <?php class RuneScape_World_Status { public $services = array(); public $timeout = 30; public $types = array('tcp', 'udp'); function add_RS_world($name, $ip, $port, $type = 'tcp', $world_status = false, $errno = '', $errstr = '') { $this->services[$name] = array( 'ip' => $ip, 'port' => $port, 'type' => $type, 'status' => $world_status, 'errno' => $errno, 'errstr' => $errstr ); } function set_world_status($name, $world_status = false) { return $this->services[$name]['world_status'] = $world_status; } function get($name) { if(in_array($this->services[$name]['type'], $this->types)) { $fp = fsockopen( "{$this->services[$name]['type']}://{$this->services[$name]['ip']}", $this->services[$name]['port'], $this->services[$name]['errno'], $this->services[$name]['errstr'], $this->timeout ); if($fp) { $this->set_world_status($name, true); } else { $this->set_world_status($name); } return $this->services[$name]['world_status']; } } function check() { foreach($this->services as $service => $value) { $this->get($service); } } function world_status($name) { return $this->services[$name]['world_status']; } function debug($var) { echo '<pre>'; print_r($var); echo '</pre>'; } function total_services() { return count($this->services); } function service($name) { return $this->services[$name]; } } ?> <center> <br /><br /><br /> <form name='RSform' method='POST'><table><tr><td> Name of the world: <td><input type='text' name='name' /><tr><td> Link to the world: <td><input type='text' name='worldlink' value='http://' /><tr><td> IP of the world: <td><input type='text' name='worldip' /><tr><td> Port of RuneScape: <td><input type='text' name='port' value='43594' /> (43594 or 43595)<tr><td></table> <input type='submit' name='submit' value='check status'> </form> </center> <?php if(isset($_POST['submit'])) { $RS_name = ($_POST['name']); $RS_world_link = ($_POST['worldlink']); $RS_world_ip = ($_POST['worldip']); $RS_port = ($_POST['port']); $world_status = new RuneScape_World_Status(); $world_status->add_RS_world('RuneScape', '64.90.181.244', '80'); $world_status->add_RS_world($RS_name, $RS_world_ip, $rs_port); $world_status->check(); echo "<br /><br /><br /><br /><center>RuneScape is: "; echo ($world_status->world_status('RuneScape')) ? '<a href=\'http://www.runescape.com/\'><font color=green><b>Online!</b></font></a>' : '<font color=red><b>Offline!</b></font>'; echo "<br /><br /><br /><br />".$RS_name." is: "; echo ($world_status->world_status($RS_name)) ? '<a href='.$RS_world_link.'><font color=green><b>Online!</b></font></a>' : '<a href='.$RS_world_link.'><font color=red><b>Offline!</b></font></a>'; } ?> </center> </body> </html> -
use urlencode to encode if first then decode it <?php echo '<a href="mycgi?foo=', urlencode($userinput), '">'; ?> more info here http://php.net/manual/en/function.urlencode.php
-
I'm Not 100% sure what your asking for here (but its lates here and i have had littel sleep) but your doing this echo " <td><input type=\"checkbox\" name=\"active_".$key."\" value=\"active\""; when personally i would do this echo " <td><input type=\"checkbox\" name=\"active[".$key."]\" value=\"active\""; the reason is, it create an array this i can access like this foreach($_POST['active'] as $k => $V) { echo "$k => $v<br>" } also you have a class which we have no info on ie read_contents_pageconf <-- whats that do ?
-
untested, but should work <?php $start = '<tr><td>'; $end = '</td>'; if(!isset($_GET['img'])) { $folder=dir("imgpath/."); $path = "imgpath"; echo '<table border="1">'; while($folderEntry=$folder->read()) { if ($folderEntry !="." & $folderEntry !=".." & $folderEntry !="folder.php" & $folderEntry !="Thumbs.db") { echo $start; echo '<a href="?p=gallery&img=' . $folderEntry . '">'; echo '<img src="' . $path . $folderEntry . '" alt="image" />'; echo $end; list($start, $end) = doSwitch($start, $end); } } if($end == '</td>') { echo '</table>'; }else{ echo '</tr></table>'; } $folder->close(); }else{ echo 'You have selected image ' . $_GET['img']; } function doSwitchA($a, $b) { if($a == '<tr><td>') { $start = '<td>'; }elseif($a == '<td>'){ $start = '<tr><td>'; } if($b == '</td>') { $end = '</td></tr>'; }elseif ($b == '</td>'){ $end = '</td>'; } return array($start, $end); } ?>
-
try using pointers doSwitch(&$start, &$end);
-
<?php $number = 1234.5678; $format_number = number_format($number, 2, '.', ''); echo $format_number; //1234.56 ?> so <?php $a = $_POST['unu']; $b = $_POST['doi']; $x = number_format(($a*$b), 2, '.', ''); ?>
-
Cool can you click solved please Bottom left
-
Try this <?php define ('DB_USER' , "lizzieni_lizzie"); define ('DB_PASSWORD' , "mac45545"); define ('DB_HOST' , "localhost"); define ('DB_NAME' , "lizzieni_website"); define ('TABLE_NAME' , "newsletter"); $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die ("No Connection:<br />" . mysql_error()); mysql_select_db (DB_NAME) OR die ('No selected database: ' . mysql_error() ); $sql="INSERT INTO newsletter (fname, lname, phone, dob, email) VALUES ('{$_POST['fname']}', '{$_POST['lname']}', '{$_POST['phone']}', '{$_POST['dob']}', '{$_POST['email']}')"; $result=mysql_query($sql) or die(mysql_error()); echo "Information sent {$result['fname']} {$result['lname']} {$result['phone']} {$result['dob']} {result['email']} "; echo "You'll receive newsletters monthly"; ?> EDIT: updated
-
you could do something like this <?php $result= mysql_query("SELECT pagedata FROM pages WHERE name = '{$_GET['page']}'"); if (mysql_num_rows($result) == 0) { echo "No page found"; exit; } $row = mysql_fetch_assoc($result); echo $row['pagedata']; ?>