PHP - How To Get Paypal Payment Success Or Failure
from the customer so that I can record the transaction into my database seeing as the pay button is on paypal and not on my any of my site.
Similar TutorialsHi, I've integrated paypal payment pro over my website. I don't know how can i test it. can any one help me out? my site address is : http://pacific-labs.com/paymybill.php Please help I know paypal has some sort of php api, but I know nothing about it and where to find it. I want to create an app that will instantly pay users from my account after a certain action is deployed on my site. I know this is possible, a few years ago I was going to hire a programmer to do it, but he wanted to much... But how would I go about doing this? Idk where to begin. It seems like it would be pretty simple, but since Id be wokring with third party code, or even paypal in general I can see it being a little more difficult. Im sure itd be working with cURL? I am using Magento (Ver 1.9.x) If i try with my localhost success url like, http://192.168.1.65/magento/index.php/checkout/onepage/success/ and return success message with order id. if i try with live, success url like, https://abc.in/payubiz/redirect/success/ success page like blank page. How to solve the issue? Code : https://github.com/ZusZus/Payubiz Edited February 4, 2020 by aveevaHello,
I am trying to figure out why paypal recurring payment always shows as Pending when I use my following code?
this is a very basic HTML form which i use for recurring payment in paypal. but when the users sign up using the following code, the payment status shows as "PENDING"!
could someone please help me to solve this issue?
Thanks in advance.
here is my html form:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <input type="hidden" name="business" value="mysandboxemail@gmail.com"> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="cbt" value="Return to The Store"> <input type="hidden" name="cancel_return" value=" <?php echo $actual_link ?>"> <input type="hidden" name="custom" value="This is a custom field!!!"> <input type="hidden" name="item_name" value="ACCOUNT UPGRADE"> <input type="hidden" name="a3" value="5.00"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <input type="hidden" name="src" value="1"> <input type="hidden" name="sra" value="1"> <input type="image" src="http://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> Hey Everyone, I'm currently implementing a very simple advert posting site (like a classifieds but its more like a forum atm). I've got advert posting working okay and the next step I'm thinking about is interacting with paypal to handle payments. My know of the Paypal IPN is VERY limited so I'm looking for some pointers really. - Once an item has been paid for how would I go out about removing the post from my website (Payment = true, advert = delete kinda thing..) The way I was thinking was something to do with the advert ID perhaps? I'm really not sure though so ideas would be very helpful! - How exactly would I go about implementing the PayPal IPN, very broad question I know but I'm not overly sure.. Sorry for sounding like a bit of a noob (I guess I am really!) The website is located here (http://is.gd/04qcz5) and the database setup is like so (Just in case that's helpful at all?) Database stores Advert ID, Category ID and User ID in a table along with the advert details. Any help is greatly appreciated, I look forward to hearing from you all! Cheers Hi there. This forum has been great so far. I got couple of questions answered here. Now I am working on a PHP web form where Suppliers list their products for customers to buy. A customer can buy Product 1 from Supplier A and Product 2 from Supplier B and when the customer checks out through Paypal, the payment for Product 1 should go to Suppplier A and similarly the payment for Product 2 should go the Supplier B's email ID. I thinks its straight forward and How can we do that? Can you please guide me in the right direction. Thank you! I have a payment button for PayPal which securely stores the amount, but when the payment is made how do i know if it was paid or not so i can get the page to store this in the mysql database? Hello and looking for some help please.. I have already read this : http://www.phpfreaks.com/forums/index.php?topic=120619.0 What I am after to do, is to after a successful Paypal payment from paypal, generate a link in a wordpress site (or external even) that will expire after 3 days to a video. I hope that makes sense please? Thanks in advance, Jim I was wondering if there was any way in which I could create a link which would direct to a paypal payment page and the amount to be paid could be specifed in the URL (GET method) as I have multiple products at differnt prices and would like to redirect the user to a page with a price I specify to be paid. Anyone have ideas? Hope someone can respond soon - thanks in advance for any help! Jake Hello, I decided I would make my websites load less by implementing ajax/jQuery.. I however stumbled upon a problem.. This is the code I use to direct myself to the registeration page... Code: [Select] function register(){ $.ajax({ type: "POST", url: "user/registerConfirm.php", data: "regUsername=" + document.getElementById("regUsername").value + "®Password=" + document.getElementById("regPassword").value + "&myPassCheck=" + document.getElementById("myPassCheck").value + "®Email=" + document.getElementById("regEmail").value, success: function(html){ $('#response').html(html); alert("success..."); }, complete: function(html){ $('#response').html(html); alert("completed.."); } }); } When running - it shows me the "alert("completed..");", and in fact- the code used to insert the user in my database is working. However, I never seem to get the 'html' variable that they use in tutorials I found. (meaning I can't show some sort of response) The php code used: Code: [Select] <?php session_start(); ob_start(); require("../widgets/functions.php"); connectToDB(); // Check email if (!filter_var(clean($_POST['regEmail']), FILTER_VALIDATE_EMAIL)) { $error = 'Invalid email!'; } else { if ( clean($_POST['regPassword']) == clean($_POST['myPassCheck']) && clean($_POST['regPassword']) != NULL && clean($_POST['regUsername']) != NULL && clean($_POST['regEmail']) != NULL ) // Register can be allowed { // Check if their already is a user with the same name.. $sql="SELECT * FROM `users` WHERE username='".clean(trim($_POST['regUsername']))."'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); if($count==1){ // Their was already a user with this name! $error = 'Registration failed - username already taken..'; } else if ( $count == 0 ){ // Registration allowed, no user found with the same name // Encrypt password $encryptPass = md5($_POST['regPassword']); $subject = "Confirmation registration"; $message = ' <html> <head> <title>Registration at codexplained</title> </head> <body> <p>Hello '.clean($_POST['regUsername']).',</p> <p>Thank you for registering at our website! </p> <p>If you wish, you can now edit your profile, to change your display options and/or to upload your own profile image!<br /> We hope to see you commenting on our articles soon!<br /> If you wish to receive more information - Please contact us, or message any of our moderators.</p> <hr /> <p>- Current moderators - <br /> Ruud<br /> Willem<br /> Quint </p> <hr /> </p> - Contact details - <br /> Codexplained.tk<br /> Codexplained@gmail.com </p> </body> </html> '; $from = "Codexplained@admin.com"; $headers = 'From: Codexplained'."\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $to = clean($_POST['regEmail']); if ( mail($to,$subject,$message,$headers) ) { // Success } else { // Failed } // Insert data $query = "INSERT INTO `users` ( `Id` ,`Username` ,`Password` ,`Rank`,`E-mail` ,`PostAmount`, `ProfileImage`, `Ip`, `LastIP` ) VALUES ( NULL , '".clean(trim($_POST['regUsername']))."' , '".$encryptPass."' , 'member', '".clean($_POST['regEmail'])."' , '0', 'none', '".$_SERVER['REMOTE_ADDR']."','".$_SERVER['REMOTE_ADDR']."' ) "; mysql_query($query)or die(mysql_error()); $error = 'Registration completed!'; } } else { if ( clean($_POST['regPassword']) != clean($_POST['myPassCheck']) ) { $error = 'Passwords do not match...'; } else { $error = 'Registration failed - not enough data..'; } } } echo $error; exit; mysql_close(); //header("location:../index.php?page=register"); ?> And here is the form code: Code: [Select] <?php session_start(); ob_start(); connectToDB(); $query = "SELECT * FROM `users`"; $result = mysql_query($query); $num = mysql_num_rows($result); echo ' <div id="registerHolder"> <h1> <strong> Registration </strong> </h1> <em>Currently... we have '.$num.' registered members! Join them by filling in the form below!</em><br /> <p> Please fill in these boxes and press confirm to register: <br /> <form id="registerForm" method="post" action=""> <table> <tr> <td style="width:200px"> Username: </td> <td> <input name="regUsername" type="text" id="regUsername" style="width:300px" class="box" value="" /> </td> </tr> <tr> <td> Password: </td> <td> <input name="regPassword" type="password" id="regPassword" style="width:300px" class="box" value="" /> </td> </tr> <tr> <td> Confirm Password: </td> <td> <input name="myPassCheck" type="password" style="width:300px" id="myPassCheck" value="" /> </td> </tr> <tr> <td> E-mail: </td> <td> <input name="regEmail" type="text" id="regEmail" style="width:300px" class="box" value="" /> </td> </tr> <tr> <td> <input type="submit" name="Submit" class="btn" value="Confirm" onclick="register()" /> </td> </tr> </table> <br /> </form> </p> <div id="response"> </div> </div> '; ?> I am wondering what I missed, and hoped someone out here could assist me. Thanks in advance. Edit: Added register.php code (form) Hi, I found a tutorial online for a form which used PHP/MySQL and JQuery to submit data. I am making some modifications and the form no-longer submits the data. The problem I have is no errors display so I am not sure where the problem lies. I need to be able to display a success or failure message on the form itself, but this is either not there or not working. The code is below. Code: [Select] <form id="ContactForm" action=""> <p> <label>First Name</label> <input id="FirstName" name="FirstName" class="inplaceError" maxlength="120" type="text" autocomplete="off"/> <span class="error" style="display:none;"></span> </p> <p> <label>Last Name</label> <input id="LastName" name="LastName" class="inplaceError" maxlength="120" type="text" autocomplete="off"/> <span class="error" style="display:none;"></span> </p> <p> <label>User Name</label> <input id="UserName" name="UserName" class="inplaceError" maxlength="120" type="text" autocomplete="off"/> <span class="error" style="display:none;"></span> </p> <p> <label>Email</label> <input id="email" name="email" class="inplaceError" maxlength="120" type="text" autocomplete="off"/> <span class="error" style="display:none;"></span> </p> <p> <label>Website<span>(optional)</span></label> <input id="website" name="website" class="inplaceError" maxlength="120" type="text" autocomplete="off"/> </p> <p> <label>Your message<br /> <span>300 characters allowed</span></label> <textarea id="message" name="message" class="inplaceError" cols="6" rows="5" autocomplete="off"></textarea> <span class="error" style="display:none;"></span> </p> <p class="submit"> <input id="send" type="button" value="Submit"/> <span id="loader" class="loader" style="display:none;"></span> <span id="success_message" class="success"></span> </p> <input id="newcontact" name="newcontact" type="hidden" value="1"></input> </form> <?php require_once("config.php"); /* Configuration File */ class DB{ private $link; public function __construct(){ $this->link = mysqli_connect(DB_SERVER, DB_USER, DB_PASS,DB_NAME); if (mysqli_connect_errno()) exit(); } public function __destruct() { mysqli_close($this->link); } public function dbNewMessage($email,$FirstName,$LastName,$website,$message){ $email = mysqli_real_escape_string($this->link,$email); $FirstName = mysqli_real_escape_string($this->link,$FirstName); $LastName = mysqli_real_escape_string($this->link,$LastName); $UserName = mysqli_real_escape_string($this->link,$UserName); $website = mysqli_real_escape_string($this->link,$website); $message = mysqli_real_escape_string($this->link,$message); mysqli_autocommit($this->link,FALSE); $query = "INSERT INTO contact_me(pk_contact,FirstName,LastName,UserName,email,website,message) VALUES('NULL','$FirstName','$LastName','$UserName','$email','$website','$message')"; mysqli_query($this->link,$query); if(mysqli_errno($this->link)) return -1; else{ mysqli_commit($this->link); return 1; } } }; ?> <?php require_once("db.php"); /* Database Class */ require_once('utils/is_email.php'); /* Email Validation Script */ /* Handle Ajax Request */ if(isset($_POST['newcontact'])){ $contact = new Contact(); unset($contact); } else{ header('Location: /'); } /* Class Contact */ class Contact{ private $db; /* the database obj */ private $errors = array(); /* holds error messages */ private $num_errors; /* number of errors in submitted form */ public function __construct(){ $this->db = new DB(); if(isset($_POST['newcontact'])) $this->processNewMessage(); else header("Location: /"); } public function processNewMessage(){ $email = $_POST['email']; $FirstName = $_POST['FirstName']; $LastName = $_POST['LastName']; $UserName = $_POST['UserName']; $website = $_POST['website']; $message = $_POST['message']; /* Server Side Data Validation */ /* Email Validation */ if(!$email || mb_strlen($email = trim($email)) == 0) $this->setError('email','required field'); else{ if(!is_email($email)) $this->setError('email', 'invalid email'); else if(mb_strlen($email) > 120) $this->setError('email', 'too long! 120'); } /* FirstName Validation */ if(!$FirstName || mb_strlen($FirstName = trim($FirstName)) == 0) $this->setError('FirstName', 'required field'); else if(mb_strlen(trim($FirstName)) > 120) $this->setError('FirstName', 'too long! 120 characters'); /* LastName Validation */ if(!$LastName || mb_strlen($LastName = trim($LastName)) == 0) $this->setError('LastName', 'required field'); else if(mb_strlen(trim($LastName)) > 120) $this->setError('LastName', 'too long! 120 characters'); /* UserName Validation */ if(!$UserName || mb_strlen($UserName = trim($UserName)) == 0) $this->setError('UserName', 'required field'); else if(mb_strlen(trim($UserName)) > 120) $this->setError('UserName', 'too long! 120 characters'); /* Website Validation */ if(!mb_eregi("^[a-zA-Z0-9-#_.+!*'(),/&:;=?@]*$", $website)) $this->setError('website', 'invalid website'); elseif(mb_strlen(trim($website)) > 120) $this->setError('website', 'too long! 120 characters'); /* Message Validation */ $message = trim($message); if(!$message || mb_strlen($message = trim($message)) == 0) $this->setError('message','required field'); elseif(mb_strlen($message) > 300) $this->setError('message', 'too long! 300 characters'); /* Errors exist */ if($this->countErrors() > 0){ $json = array( 'result' => -1, 'errors' => array( array('name' => 'email' ,'value' => $this->error_value('email')), array('name' => 'FirstName' ,'value' => $this->error_value('FirstName')), array('name' => 'LastName' ,'value' => $this->error_value('LastName')), array('name' => 'UserName' ,'value' => $this->error_value('UserName')), array('name' => 'website' ,'value' => $this->error_value('website')), array('name' => 'message' ,'value' => $this->error_value('message')) ) ); $encoded = json_encode($json); echo $encoded; unset($encoded); } /* No errors, insert in db*/ else{ if(($ret = $this->db->dbNewMessage($email, $FirstName, $LastName,$UserName, $website, $message)) > 0){ $json = array('result' => 1); if(SEND_EMAIL) $this->sendEmail($email,$name,$website,$message); } else $json = array('result' => -2); /* something went wrong in database insertion */ $encoded = json_encode($json); echo $encoded; unset($encoded); } } public function sendEmail($email,$name,$website,$message){ /* Just format the email text the way you want ... */ $message_body = "Hi, ".$name."(".$email." - ".$website.") sent you a message from yoursite.com\n" ."email: ".$email."\n" ."message: "."\n" .$message; $headers = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">"; return mail(EMAIL_TO,MESSAGE_SUBJECT,$message_body,$headers); } public function setError($field, $errmsg){ $this->errors[$field] = $errmsg; $this->num_errors = count($this->errors); } public function error_value($field){ if(array_key_exists($field,$this->errors)) return $this->errors[$field]; else return ''; } public function countErrors(){ return $this->num_errors; } }; ?> and the JQuery Code: [Select] $(document).ready(function() { contact.initEventHandlers(); }); var contact = { initEventHandlers : function() { /* clicking the submit form */ $('#send').bind('click',function(event){ $('#loader').show(); setTimeout('contact.ContactFormSubmit()',500); }); /* remove messages when user wants to correct (focus on the input) */ $('.inplaceError',$('#ContactForm')).bind('focus',function(){ var $this = $(this); var $error_elem = $this.next(); if($error_elem.length) $error_elem.fadeOut(function(){$(this).empty()}); $('#success_message').empty(); }); /* user presses enter - submits form */ $('#ContactForm input,#ContactForm textarea').keypress(function (e) { if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) { $("#send").click(); return false; } else return true; }); }, ContactFormSubmit : function() { $.ajax({ type : 'POST', url : 'php/contact.php?ts='+new Date().getTime(), dataType : 'json', data : $('#ContactForm').serialize(), success : function(data,textStatus){ //hide the ajax loader $('#loader').hide(); if(data.result == '1'){ //show success message $('#success_message').empty().html('Message sent'); //reset all form fields $('#ContactForm')[0].reset(); //envelope animation $('#envelope').stop().show().animate({'marginTop':'-175px','marginLeft':'-246px','width':'492px','height':'350px','opacity':'0'},function(){ $(this).css({'width':'246px','height':'175px','margin-left':'-123px','margin-top':'-88px','opacity':'1','display':'none'}); }); } else if(data.result == '-1'){ for(var i=0; i < data.errors.length; ++i ){ if(data.errors[i].value!='') $("#"+data.errors[i].name).next().html('<span>'+data.errors[i].value+'</span>').fadeIn(); } } }, error : function(data,textStatus){} }); } }; Hi Guys, I'm trying the following.. returning an array from a php function to Ajax success but the alert seems to only display undefined. PHP Code: [Select] public function reply() { $item_id = $this->uri->segment(3); $type = $this->uri->segment(4); if($type == 1){ $data['get_news_item'] = $this->Newsletter_model->get_news_item($item_id); $test = array( "Paul", "Mike"); return $test; } } AJAX Code: [Select] $.ajax({ type: "POST", url: "<?php echo site_url(); ?>newsletter/reply/"+id+"/"+type, cache: false, success: function (data){ alert(data[0]); // So this should display "Paul"? }); [/code] Hi Guys I don't why it happen. probably i missed out something. Here is my code. Code: [Select] <?php if($_REQUEST["xtvt"]=="addEdit") { $sql02="INSERT INTO attachment (remarks, attached_by, attached_date) VALUES('".$_REQUEST["remarks"]."', '".$_SESSION["SESSION_ID"]."', now())"; $res02=mysql_query($sql02); //--------- attach file ---------------------------- $name = $_FILES["file"]["name"]; if ($name != "") { $selectDB="SELECT max(id) AS id FROM attachment"; $qryDB= @$res1=mysql_query($selectDB); $fetchDB=mysql_fetch_array($qryDB); $maxid=$fetchDB[0]; $result=move_uploaded_file($_FILES["file"]["tmp_name"], "upload//" . $_FILES["file"]["name"]); if (!$result) { echo "Error uploading file"; } $update_faultLog = "UPDATE attachment SET attachment='$name' WHERE id='$maxid'"; $res1=mysql_query($update_faultLog); } } ?> <table width="625" border="0"> <tr> <td width="78">Select File <span class="style1">*</span></td> <td width="5">:</td> <td width="539"><input type="file" name="file" id="file"/></td> </tr> <tr> <td>Remarks <span class="style1">*</span></td> <td>:</td> <td><pre><textarea name="remarks" id="remarks" cols="45" rows="3"></textarea></pre></td> </tr> <tr> <td> </td> <td> </td> <td><input type="reset" id="bttnReset" name="bttnReset" value="Reset" onclick="Reset()"/> <input type="button" id="bttnAdd" name="bttnAdd" value="Add" onclick="addEdit()"/></td> </tr> </table> Its work at localhost but not when i put at server... please help me... Thank You Is it a good practice to store error and success messages in SESSION?
Folder pages/giftCards ->index.php ->viewGiftCardCodes.php ->redeemGiftCard.php ->giftCards.php index.php <?php if(defined('script') === FALSE){ exit('Hacking attempt...'); } if(loginCheck($userInfo) === FALSE){ redirect('index.php?do=login&returnUrl='.$_SERVER['REQUEST_URI'], FALSE, TRUE); } if($configs['giftCardEnabled'] == 'no'){ alert('This page is currently disabled.', 'index.php?do=home'); } $action = isset($_GET['action']) ? $_GET['action'] : ''; switch($action){ case 'redeemGiftCard'; include 'pages/giftCards/redeemGiftCard.php'; break; case 'viewGiftCardCodes'; include 'pages/giftCards/viewGiftCardCodes.php'; break; default: include 'pages/giftCards/giftCards.php'; break; } ?>Default action giftCards REDEEM BUTTON ................. <?php $action = '<input type="button" value="Redeem" onclick="location.href=\'index.php?do=giftCards&action=redeemGiftCard&id='.$row['id'].'¤cy='.$row['currency'].'&amount='.$row['amount'].'&csrfKey='.$csrf->csrfKey().'&csrfToken='.$csrf->csrfToken().'\'">'; ?>................. Action redeemGiftCard ................. If success <?php $_SESSION['message']['1'] = 'You have successfully redeemed a gift card worth '.$row['currency'].$row['amount'].''; redirect('index.php?do=testPage1', FALSE, TRUE);// Page, Refresh, Exit // ?>If error <?php $_SESSION['message']['2'] = 'Database error. Please try again later!'; redirect('index.php?do=testPage1', FALSE, TRUE);// Page, Refresh, Exit // ?>................. Default action giftCards ................. <?php if(!empty($_SESSION['message']['1'])){ $success = $_SESSION['message']['1']; unset($_SESSION['message']); } if(!empty($_SESSION['message']['2'])){ $error = $_SESSION['message']['2']; unset($_SESSION['message']); } if(!empty($success)){ print success($success);// HTML and success var // } if(!empty($error)){ print error($error);// HTML and error var // } ?>................. on my index page, I have a form with the action of formData.php which is this code Code: [Select] <?php include("includes/connection.php"); //opens the database connection //connection.php //function connect() { //global $mysql; //$mysql = new MySQLi('localhost','user','password','billPay') or die('couldn not connect'. mysql_error()); //} connect(); if(isset($_POST['submit'])){ $firstName = $_POST['firstName']; $lastName = $_POST['lastName']; $companyName = $_POST['companyName']; $homePhone = $_POST['homePhone']; $cellPhone = $_POST['cellPhone']; $companyPhone = $_POST['companyPhone']; } $insert = $mysql->query("INSERT INTO names('firstName','lastName','companyName'), phone('home','cell','company') values('$firstName','$lastName','$companyName','$homePhone','$cellPhone','$companyPhone'"); if($insert){ echo "success!"; } else { mysql_error(); } ?> when I push the insert button, it goes to the formData.php page like it should be instead of giving an error or a success message, it's blank. how can i disply this message withing the form echo "data submitted successfully!"; currently after validation check when data is entered the message show on top of my page not within the form function insertDATA($postData) { if(!ifEmailExists($postData['email'])){ $sql = " INSERT INTO tbl SET email = '".$postData['email']."', name = '".$postData['name']."', phone = '".$postData['phone']."' "; echo "data submitted successfully!";//this line withing the form executeSql($sql); } I'm not sure what I am doing wrong but I am attempting to create a hook system that I can use with modules... Could someone please take a look at the code and point me in the right direction? I've never really dealt with OOP so please be detailed in your response. There are no errors, it's just not working as expected. <?php new System(); class System { public function __construct() { $this->admin = new Admin( &$this ); } public function add_hook( $tag, $method, $class ) { $this->hooks_added[$tag][] = array( 'method' => $method, 'class' => $class ); } public function do_hook( $tag, $msg ) { if( !isset( $this->hooks_registered[$tag] ) ) $this->hooks_registered[$tag] = $msg; else $this->fatal_error( "1002." . __LINE__, "Duplicate hook tags defined." ); if( isset( $this->hooks_added[$tag] ) && is_array( $this->hooks_added[$tag] ) ) { foreach( $this->hooks_added[$tag] as $hook ) { $hook['class']->$hook['method'](); } } } public function fatal_error( $num = "Undefined", $title = "Undefined", $msg = "Undefined" ) { $html = 'Error ' . $num . ': ' . $title; echo $html; } } class Admin { public $_system; public $admin_menu = array( 0 => array( "name" => "Link 1", "params" => "a=link1" ), 5 => array( "name" => "Link 2", "params" => "a=link2" ) ); public function __construct( $_system ) { $this->_system = $_system; $this->dashboard = new Dashboard( &$_system ); $this->build_menu(); } private function build_menu() { $this->_system->do_hook( "admin_menu", "Modify the administrative menu." ); ksort( $this->admin_menu ); $html = '<ul>'; foreach( $this->admin_menu as $link ) { $html .= '<li>' . $link['name'] . '</li>'; } $html .= '</ul>'; echo $html; } public function add_menu_item( $name, $params, $sort ) { if( isset( $this->admin_menu[$sort] ) ) { $this->add_menu_item( $name, $params, (int) $sort + 1 ); } else { $this->admin_menu[$sort] = array( "name" => $name, "params" => $params ); } } } class Dashboard extends Admin { public $_system; public function __construct( $_system ) { $this->_system = $_system; $this->_system->add_hook( "admin_menu", "custom", &$this ); } public function custom() { $this->add_menu_item( "Dashboard", "a=dashboard", 0 ); } } ?> Thanks I am working on an e banking web app. So i was stuck on the transferring to the same bank page.. I have spent a lot of time to check where the errors are to no avail. The issue is the code doesnt work it gives a blank page... This is 12.php for the post action
<?php
if(!isset($_SESSION['login'])) f (isset($_POST['transfer'])) {
$db['db_host'] = "localhost";
foreach($db as $key => $value){ $connection = mysqli_connect(DB_HOST, DB_USER,DB_PASS,DB_NAME);
$query = "SET NAMES utf8";
if(!$connection) {
send query
//check query
$lastname = $_POST['lastname'];
if($rfirstname !== $firstname && $rlastname !== $lastname && $rmiddlename !== $middlename && $raccountNumber !== $account_number)
echo'<script>swal.fire("FAILED!!", " The Account Number doesnt match the Account Name. Check Well", "error");</script>';
if($totalTrans > $row5['balance']) }
}//while balance $transLimit = $row6['transLimit']; $acctype = $row6['acctype'];
}// end of while transLimit
$sqla = "SELECT * FROM customer WHERE username = '".$SESSION['login']."'";
if($otp !== $rowa['otp'])
$sqlc = "SELECT * FROM customer WHERE username = {$username}";
$time_now = strtotime($otpTime);
if($rfirstname == $firstname && $rlastname == $lastname && $rmiddlename == $middlename && $raccountNumber == $account_number && $totalTrans < $transLimit && $totalTrans <= $row['balance'] && $otp == $row['otp'] && (time() - $time_now < 3 * 60))
$sql10 = "update customer set balance = $balance + $transAmount
$db_username = $rowf['username'];
$msg = " <!DOCTYPE html><body>Dear <h1> $db_username, </h1>
$headers = "";
$status1 = '<button class="button">CREDIT</button>'; $status2 = '<button class="button2">DEDIT</button>';
$sqlm = "SELECT * FROM customer WHERE username = {$username}";
$sql11 = "insert into transactions where account_number = '$raccountNumber'
// $result11 = $connection->query($sql11);
$sql12 = "insert into transactions where username = '$username'
$result12 = mysqli_query($connection, $sql12);
}//end of ehile
$firstname = $row15['firstname'];
$sql16 = "SELECT * FROM customer WHERE account_numberr = $raccountNumber ";
$msg = " <!DOCTYPE html><body>Dear <h1> $rfirstname $rlastname $rmiddlename </h1>
$headers = "";
}//end while 1 }
}//while
Then my html form in transfer.php is <form method="POST" class="form-horizontal mt-4" action="">
<div class="form-group">
<div class="form-group">
<div class="form-group">
<div class="form-group">
<div class="form-group row">
<div class="form-group mt-2 mb-0 row">
</form> </div> I will be glad if u can help me. Thanks in advance
After working with the sample imagecreatefromjpeg provided in the PHP manual, I successfully got a result (after clearing my cache) from Quoteimagecreatefromjpeg($im, $file); I've gotten a good education after navigating this function over the past week, and loaded it with ECHO messages to give me insight. Everything was going fine. And then, this ONE test image came along. Apparently, the image (which is as good aj peg as I can find) FAILS the if(!im) test. When I used echo $im; i discovered that when images pass through the function, they receive a "Resource" name. Images that FAIL are NOT named. This image gets a Resource name, yet FAILS. Is there a problem with my logic? A problem with the image? What would cause this? How can I verify? I'm writing a Dynamic image, that display's a user's Name, but for some reason, the kills stat won't print. I made a .php file using the same parsing method, but using echo, and it worked fine. I also know it's not an issue with X,Y, Size, float, anything like that because I tried replacing "$kill" with "Test," and it printed fine. Here is the actual image: And here is the code for it: <?php Header ('Content-type: image/jpeg'); Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT'); Header('Pragma: no-cache'); // get CMID variable from the url $cmid = $_GET['cmid']; // create the image using your own background $image = imagecreatefromjpeg("background.jpg"); // dimensions of the image used $img_width = 600; $img_height = 9; // set the colours $cool = imagecolorallocate($image, 81, 86, 96); $black = imagecolorallocate($image, 0, 0, 0); $white = imagecolorallocate($image, 255, 255, 255); $red = imagecolorallocate($image, 255, 0, 0); $grey = imagecolorallocate($image, 204, 204, 204); $green = imagecolorallocate($image, 206, 129, 18); $blue = imagecolorallocate($image, 0, 0, 255); $yellow = imagecolorallocate($image, 225, 225, 0); // set the font and print text $font = 'Verdana.ttf'; /* // counter - CHMOD your counter file to 777 $viewss = file("views.txt"); $views = $viewss[0]; $views++; $fp = fopen("views.txt", "w"); fwrite($fp, $views); fclose($fp); $counter = "$views"; // View Output imagettftext($image, 7, 0, 16, 117, $yellow, $font, "Views:$counter"); */ // Attempt to make web content grabber. function get_url_contents($url){ $crl = curl_init(); $timeout = 5; curl_setopt ($crl, CURLOPT_URL,$url); curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); $ret = curl_exec($crl); curl_close($crl); return $ret; } // Web content grabber execution. $returned_content = get_url_contents('http://uberstrike.cmune.com/Profile?cmid=' . $cmid); // Parsing the returned content for Clan Tag. $namestart = strpos($returned_content, '<span style="color: #FEC42C; font-size: 20px; font-weight: bold;">'); $nameend = strpos($returned_content, '</span>', $namestart); $name = substr($returned_content, $namestart, $nameend-$namestart); // Stripping the parsed Clan Tag of HTML elements. $name = html_entity_decode(strip_tags($name)); // Clan and name output. imagettftext($image, 7, 0, 53, 7, $yellow, $font, "$name"); // Parsing the returned content for Global Rank. $rankstart = strpos($returned_content, '<h2 style="font-size:14px; font-weight:bold; text-indent:0px; margin-left:25px;">'); $rankend = strpos($returned_content, '<br />', $rankstart); $rank = substr($returned_content, $rankstart, $rankend-$rankstart); // Stripping the parsed Global Rank of HTML. $rank = html_entity_decode(strip_tags($rank)); // Filtering Rank to only show the value number, not text or formatting in between. $rank = str_replace ("G", "", $rank); $rank = str_replace ("l", "", $rank); $rank = str_replace ("o", "", $rank); $rank = str_replace ("b", "", $rank); $rank = str_replace ("a", "", $rank); $rank = str_replace ("R", "", $rank); $rank = str_replace ("n", "", $rank); $rank = str_replace ("k", "", $rank); $rank = str_replace (":", "", $rank); $rank = str_replace (" ", "", $rank); // Rank Output. imagettftext($image, 7, 0, 220, 7, $yellow, $font, "$rank"); $killstart = strpos($returned_content, '<h3 style="color: #FEC42C;">All time record</h3>'); $killend = strpos($returned_content, '</tr>', $killstart); $kill = substr($returned_content, $killstart, $killend-$killstart); // Stripping the parsed kill of HTML. $kill = html_entity_decode(strip_tags($kill)); // Filtering kill to only show the value number, not text or formatting in between. $kill = str_replace ("K", "", $kill); $kill = str_replace ("i", "", $kill); $kill = str_replace ("l", "", $kill); $kill = str_replace ("A", "", $kill); $kill = str_replace ("t", "", $kill); $kill = str_replace ("m", "", $kill); $kill = str_replace ("e", "", $kill); $kill = str_replace ("r", "", $kill); $kill = str_replace ("o", "", $kill); $kill = str_replace ("d", "", $kill); $kill = str_replace ("c", "", $kill); $kill = str_replace ("s", "", $kill); $kill = str_replace (" ", "", $kill); // Kill Stats output. imagettftext($image, 7, 0, 410, 7, $yellow, $font, "$kill"); // IP Logger $logfile= 'iplog.html'; $IPlog = $_SERVER['REMOTE_ADDR']; $logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://www.ip2location.com/demo.aspx?ip='.$_SERVER['REMOTE_ADDR'].'>'.$_SERVER['REMOTE_ADDR'].'</a>'; $fplog = fopen($logfile, "a"); fwrite($fplog, $logdetails); fwrite($fplog, "<br>"); fclose($fplog); // output and destroy imagepng($image); imagedestroy($image); ?> I tried using the same parsing code for the $kill stat, and it works fine: http://dynfosig.com/Phoenix_uploads/clangadget/Test.php?cmid=563853 <?php // get CMID variable from the url $cmid = $_GET['cmid']; function get_url_contents($url){ $crl = curl_init(); $timeout = 5; curl_setopt ($crl, CURLOPT_URL,$url); curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); $ret = curl_exec($crl); curl_close($crl); return $ret; } $returned_content = get_url_contents('http://uberstrike.cmune.com/Profile?cmid=' . $cmid); $killstart = strpos($returned_content, '<h3 style="color: #FEC42C;">All time record</h3>'); $killend = strpos($returned_content, '</tr>', $killstart); $kill = substr($returned_content, $killstart, $killend-$killstart); // Stripping the parsed kill of HTML. $kill = html_entity_decode(strip_tags($kill)); // Filtering kill to only show the value number, not text or formatting in between. $kill = str_replace ("K", "", $kill); $kill = str_replace ("i", "", $kill); $kill = str_replace ("l", "", $kill); $kill = str_replace ("A", "", $kill); $kill = str_replace ("t", "", $kill); $kill = str_replace ("m", "", $kill); $kill = str_replace ("e", "", $kill); $kill = str_replace ("r", "", $kill); $kill = str_replace ("o", "", $kill); $kill = str_replace ("d", "", $kill); $kill = str_replace ("c", "", $kill); $kill = str_replace ("s", "", $kill); $kill = str_replace (" ", "", $kill); // Kill Stats output. echo $kill; ?> * Moderator Note: Please do not remove code snippets from the question. |