Jump to content

CodeMaster

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

About CodeMaster

  • Birthday 12/15/1986

Profile Information

  • Gender
    Male
  • Location
    Amsterdam

CodeMaster's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. $pgID = array("home", "about", "mixology", "blogs", "press", "contact"); The error was generated by the [...] on line 4. You can use the code above or remove the [].
  2. What does error_reporting say? <?php error_reporting(2047); ini_set("display_errors",1); ?> You might want to use in_array (http://us.php.net/in_array) instead of a for loop. (array_key_exists("ID", $_GET) && in_array($_GET["ID"], $pgID)) ? require_once(sprintf("include_path/%s", $gdID[$ID])) : require_once("home.php");
  3. You start output buffering at line 2. Why? That might be the problem. You cannot do header("location... while output buffering is on. So I suppose you have a good reason for output buffering, but if not, you might just want to remove that. <?php $host="localhost"; // Host name $username="mcdtech1"; // Mysql username $password="l0608448533"; // Mysql password $db_name="mcdtech1_lakeAlanH"; // Database name $tbl_name="users"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { ob_start(); echo "Wrong Username or Password"; ob_end_flush(); } ?>
  4. Personally I would recommend to learn OOP by learning Java or something. These languages are much more into OOP than PHP is. I did not understand OOP in PHP, before I learned Java myself. If you want to apply OOP you must know why OOP is so useful. PHP is just a wannabee OOP language. But it is really useful when building large systems. With OOP you can easily overwrite a class method, without replacing the whole class. So if it is supposed to be modulair system, than I would recommend it. If just a small website, no need to use classes. I will post you a copy of a class I made for overwriting a default class in PHP: mysqli. You will see why it is useful. I can overwrite the query method in mysqli, but the other methods remain the same. class mysqli_advanced extends mysqli { public function query($query) { if (!$result = parent::query($query)) { throw new mysqlExp(); } else { return $result; } } } In PHP I would further recommend using classes for building your own exceptions. Which can be useful for logging errors or something. http://www.brandonsavage.net/exceptional-php-extending-the-base-exception-class/
  5. Hm ok. So the problem is that you see the response in the browser, while you need it in a string so you can redirect to it with PHP. Right? I think curl will be a good solution here. So instead of a form, you simulate the get request with CURL. Then you get the response in a string and then you can apply my code. Something like: <?php $ch = curl_init(); # Fill out your form parameters in the string below $queryStr = sprintf( "?CustomerID=%s&UserName=%s&Amount=%s&etc=%s&etc=%s" $CustomerID, $UserName, $Amount, $etc, $etc ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://nz.ewaygateway.com/Request/" . $queryStr); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); preg_match('/<URI>(.*)?<\/URI>/', $response, $match); header(sprintf("location: %s, $match[0])); ?>
  6. You might want to use mysql_num_rows().
  7. You might want to hire a freelancer for this.
  8. The code I gave you does that. Please be more clear about what you want to do. Post us your code.
  9. You forgot to declare the From parameter in the headers. You can use the content-type parameters as well.
  10. So how did replacing the <? with <?php work out? Did it work?
  11. What is the ouput if you try this function instead? function includefile($filename) { try { include($filename); } catch (Exception $e) { die($e->getMessage()); } }
  12. What exactly is your goal with that? You can use PHP CURL to login to a website. Let me know
×
×
  • 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.