The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

PHP Pages

3 posters

Go down

PHP Pages Empty PHP Pages

Post by Remscar May 30th 2011, 12:59 am

I know there is a way to create HTML pages on your website, however i would like to implement a small php page that interfaces with my own MySQL database and does some special things. I already have a website hosted by you (gamersaddicted.net). I would love your feedback, thanks.

Here is the code for the php

Code:
<?php
$time = time()
?>

<?php
$req = 'cmd=_notify-synch';

$tx_token = $_GET['tx'];
$auth_token = "xxx";
$req .= "&tx=$tx_token&at=$auth_token";

$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
// $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {
} else {
fputs ($fp, $header . $req);
$res = '';
$headerdone = false;
while (!feof($fp)) {
$line = fgets ($fp, 1024);
if (strcmp($line, "\r\n") == 0) {
$headerdone = true;
}
else if ($headerdone)
{
$res .= $line;
}
}

$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}

$con = mysql_connect("xxx:3306","user","pass"); //Connect to the MySQL Database that GForts uses


if (!$con)
   {
   die("Could not connect: " . mysql_error());
   }
   

   
$db_selected = mysql_select_db("gamereso_donation", $con); //Connect to the table that contains GForts info
//$db_selected_2 = mysql_select_db("TABLENAME",$con2); //Select the table that has the forum or donation tracker

$firstname = $keyarray['first_name'];
$itemname = $keyarray['item_name'];
$amount = $keyarray['payment_gross'];
$payer = $keyarray['payer_email'];
$itemnumber = $keyarray['item_number'];
$txn = $keyarray['txn_id'];
$quantity = $keyarray['quantity'];
$option1 = $keyarray['option_selection1'];

echo ("<p><h3>Thank you for your purchase!</h3></p>");

$sql = "SELECT * from gf_dcs WHERE TID='".$txn."'";
$result = mysql_query($sql,$con);
$data = mysql_fetch_array($result,MYSQL_ASSOC);

if($data != false) { // Check to see if this page has already been accessed before
$dtime = date("Y-m-d", $data["CREATED"]);
$amount = $data["AMOUNT"];
$code = $data["CODE"];
$used = $data["USED"];

echo("<li>You donated for donator rank! Go on the server to redeem it!</li>\n\n");

if ($used == 0) {

echo("<li>Your code is:</li>\n");
echo("<p><h2>" . $code . "</h2></p>");

} else {

echo("<li>Your code has been used.</li>\n");

}



}
else
{
//Create the code for them
$CODE = "S";

for ($i=1; $i<=25; $i++)
{
$A = rand(0,1);
   if ($A==0)
   {
      $A = rand(0,9);
      
      $CODE .= $A;
   }
   else
   {
      $A = rand(1,26);
      $T = chr(64+$A);
      $CODE .= $T;
   }
   
}



$sql = "INSERT INTO gf_dcs VALUES ('$CODE',1,1,0,$time,'$txn')"; // Inset the data into gforts database
$result = mysql_query($sql,$con);
echo("<li>Your code is:</li>\n");
echo("<p><h2>" . $CODE . "</h2></p>");




}


mysql_close($con);


}
else if (strcmp ($lines[0], "FAIL") == 0) {
}
}

fclose ($fp);

ssi_shutdown();

?>



avatar
Remscar
New Member

Posts : 3
Reputation : 0
Language : English

Back to top Go down

PHP Pages Empty Re: PHP Pages

Post by Rac May 30th 2011, 1:11 am

As far as I know you can't add php pages, but you could try adding it to a HTML page and making it an external PHP page to add where you want.
avatar
Rac
Forumember

Male Posts : 39
Reputation : 1
Language : English, French, German
Location : England

http://jhgamesforums.forumotion.co.uk

Back to top Go down

PHP Pages Empty Re: PHP Pages

Post by Remscar May 30th 2011, 7:05 am

I don't think my client has an external web server that can host the page. Is there a way to use PHP in the html pages?
avatar
Remscar
New Member

Posts : 3
Reputation : 0
Language : English

Back to top Go down

PHP Pages Empty Re: PHP Pages

Post by Rac May 30th 2011, 4:49 pm

If you just add your PHP script to a HTML page it should work fine.
avatar
Rac
Forumember

Male Posts : 39
Reputation : 1
Language : English, French, German
Location : England

http://jhgamesforums.forumotion.co.uk

Back to top Go down

PHP Pages Empty Re: PHP Pages

Post by Remscar May 30th 2011, 7:59 pm

Rac wrote:If you just add your PHP script to a HTML page it should work fine.

No it doesnt.
avatar
Remscar
New Member

Posts : 3
Reputation : 0
Language : English

Back to top Go down

PHP Pages Empty Re: PHP Pages

Post by Rac May 30th 2011, 8:06 pm

I don't think you can then Sad

Edit: Yea, you can't use PHP in forumotion, I did some research and found out Smile
avatar
Rac
Forumember

Male Posts : 39
Reputation : 1
Language : English, French, German
Location : England

http://jhgamesforums.forumotion.co.uk

Back to top Go down

PHP Pages Empty Re: PHP Pages

Post by kirk May 31st 2011, 5:27 pm

yeah but you might be able to convert it to html.
I would have to see the script and what it is you want it to do.
kirk
kirk
Forumaster

Male Posts : 11037
Reputation : 653
Language : English,Vulcan,Klingon, Romulan,& Gorn

Back to top Go down

PHP Pages Empty Re: PHP Pages

Post by Rac May 31st 2011, 5:33 pm

The scripts in the first post and I think it's meant to generate a code for you after donating.
avatar
Rac
Forumember

Male Posts : 39
Reputation : 1
Language : English, French, German
Location : England

http://jhgamesforums.forumotion.co.uk

Back to top Go down

PHP Pages Empty Re: PHP Pages

Post by kirk May 31st 2011, 5:43 pm

Do you have a site/page that this code is working on now?
And where did you want to incorporate this on your forumotion forum?
kirk
kirk
Forumaster

Male Posts : 11037
Reputation : 653
Language : English,Vulcan,Klingon, Romulan,& Gorn

Back to top Go down

PHP Pages Empty Re: PHP Pages

Post by Rac May 31st 2011, 6:01 pm

Remscar wrote:I don't think my client has an external web server that can host the page

I'm guessing no.

avatar
Rac
Forumember

Male Posts : 39
Reputation : 1
Language : English, French, German
Location : England

http://jhgamesforums.forumotion.co.uk

Back to top Go down

PHP Pages Empty Re: PHP Pages

Post by kirk May 31st 2011, 10:09 pm

no but i am sure you create a html code to do what ever the code is doing for the php script.

If i seen the page to where you have the php working on your website or where ever you have it? i might be able to suggest how to get the same thing or something similar?
kirk
kirk
Forumaster

Male Posts : 11037
Reputation : 653
Language : English,Vulcan,Klingon, Romulan,& Gorn

Back to top Go down

PHP Pages Empty Re: PHP Pages

Post by Rac May 31st 2011, 11:34 pm

I'l let him answer that one Confused

Cool avatar though kirk
avatar
Rac
Forumember

Male Posts : 39
Reputation : 1
Language : English, French, German
Location : England

http://jhgamesforums.forumotion.co.uk

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum