Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - dmcb

Pages: [1] 2
1
i got it working, submitted the form to a page on my website first, which auto submitted the paypal link

2
Sorry the second piece of code should be this

Code: [Select]
<center><p> <form action="https://www.paypal.com/cgi-bin/webscr" method="post">        <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="derek.skybc3@gmail.com"> <?php paypal_items(); ?> <input type="hidden" name="currency_code" value="EUR"> <input type="hidden" name="amount" value="<?php echo $total?>"> <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but03.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> </p></center>


3
The problem i am having is that when i change a link in a form a sql query wont work.

the query works when i use this link(index3.php) in the form, this is a link  from my website.

Code: [Select]
<center><p>
<form action="index3.php" method="post">
                         <input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="derek.skybc3@gmail.com">
<?php paypal_items(); ?>
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="amount" value="<?php echo $total?>">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click- but03.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
</p></center>


But the query does not work when i use this link(https://www.paypal.com/cgi-bin/webscr) in the form. this is a link to the paypal website


Code: [Select]
<center><p>
<form action="index3.php" method="post">
        <input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="derek.skybc3@gmail.com">
<?php paypal_items(); ?>
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="amount" value="<?php echo $total?>">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but03.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
</p></center>


is this because the paypal link is an external link ???
Can anyone help please and does anyone know how i could get the query working with the paypal link in the form ??

4
General PHP Help / submitting a form using a external link
« on: April 26, 2012, 08:44:24 AM »
Hi,

i'm having problems submitting a form using an external web address link.
i use an if statement to check if the form button is pressed,and if it is the database is updated.
it worked for me when i used an internal link from my website but not when i used an exteranl link.
can anyone help ?

this is the form with an internal link, which works

Code: [Select]
<center><p>
<form action="index3.php" method="post">
                         <input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="derek.skybc3@gmail.com">
<?php paypal_items(); ?>
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="amount" value="<?php echo $total?>">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-       but03.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
</p></center>

and this is the if statement and query

PHP Code: [Select]

if (isset ($_POST['submit_x']) )    //////_x needs to be added to submit because it is a image button
	
	
	
	
	
{
	
	
	
	
	
$user_id $_SESSION['user_id'];
	
	
	
	
	
$get mysql_query("SELECT firstname, lastname, id FROM users WHERE id='$user_id '" ); // int means interger is only being passed for secuirty;
	
	
	
	
    while (
$get_row mysql_fetch_assoc($get) ){
	
	
	
	
	
$firstname $get_row['firstname'];
	
	
	
	
	
$lastname $get_row['lastname'];
	
	
	
	
	
$persons_id $get_row['id'];
	
	
	
	
	
$rented_movie $name;
	
	
	
	
	
$date_rented date("d F Y"); // function thats gets todays date
	
	
	
	
	
$d date(" d ");
                    
$d $d +2// adding 2 to todays date 
                    
$due_back date("$d F Y "); // date rental is due back
	
	
	
	
	

	
	
	
	
	
$query "INSERT INTO rentals VALUES('','$firstname $lastname','$persons_id','$rented_movie','$date_rented','$due_back' )"//query that inserts data the users entered in the sign up form into the database
	
	
	
	
	
$query_run mysql_query($query);
	
	
	
	
	

	
	
	
	
	

	
	
	
	
	
}



this is the code when i use the exteranl link which does work and update the database

Code: [Select]
<center><p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
        <input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="derek.skybc3@gmail.com">
<?php paypal_items(); ?>
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="amount" value="<?php echo $total?>">
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but03.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
</p></center>

5
General PHP Help / Shopping cart problem
« on: March 26, 2012, 09:15:51 AM »
Hi just wondering if anyone can help me. i am trying to get a shopping cart working and am having a few problems. on the webpage the user has 2 option to rent or buy. the problem that i am having is that if i click rent, it adds the rental and buy option to the shopping cart, the same thing happens if i click the buy button.

The Hangover Part II x 1@ €3.99= €3.99[-]
  • [Delete]

The Hangover Part II x 1@ €7.99= €7.99[-]
  • [Delete]


Total: €11.98

I have tried everything i can think of but cant get it working properly can anyone help please. the code follows

 
PHP Code: [Select]

<?php



session_start
();
$page 'index2.php';

if(isset (
$_GET['addrent']) ){
	
$quantity mysql_query('SELECT id, quantity FROM movies WHERE id='.mysql_real_escape_string((int)$_GET['addrent']));
	
while(
$quantity_row mysql_fetch_assoc($quantity) ){
	
	
if(
$quantity_row['quantity'] != $_SESSION['cart2_'.(int)$GET['addrent'] ])
	
	
{
	
	
	
$_SESSION['cart2_'.(int)$_GET['addrent']] +='1';
	
	
}
	
}
	
header('Location: '.$page);
}


if(isset (
$_GET['addbuy']) ){
	
$quantity mysql_query('SELECT id, quantity FROM movies WHERE id='.mysql_real_escape_string((int)$_GET['addbuy']));
	
while(
$quantity_row mysql_fetch_assoc($quantity) ){
	
	
if(
$quantity_row['quantity'] != $_SESSION['cart2_'.(int)$GET['addbuy'] ])
	
	
{
	
	
	
$_SESSION['cart2_'.(int)$_GET['addbuy']] +='1';
	
	
}
	
}
	
header('Location: '.$page);
}


if(isset(
$_GET['remove']) ) {
	
$_SESSION['cart2_'.(int)$_GET['remove']]--;
	
header('Location: '.$page);
}

if(isset(
$_GET['delete']) ) {
	
$_SESSION['cart2_'.(int)$_GET['delete']]='0';
	
header('Location: '.$page);
}

function 
products() {
	
$get mysql_query("SELECT image, id, name, description, rent FROM movies WHERE quantity > 0 ORDER BY id DESC "
	
);
	
if(
mysql_num_rows($get) == 0){
	
	
echo 
"there are no products to display";
	
}else{
	
	
while(
$get_row mysql_fetch_assoc($get) ){
	
	

	
	
$get_row['name'];
	
	
$get_row['description'];
	
	
$get_row['image'];
	
	
$get_row['rent'];
	
	

	
	
$name $get_row['name'];
	
	
$description $get_row['description'];
	
	
$image $get_row['image'];
	
	
$rent_price '€'.number_format($get_row['rent'], 2);
	
	
$add '<a href="cart2.php?addrent='.$get_row['id'].'">Rent</a>';
	
	
$add1 '<a href="cart2.php?addbuy='.$get_row['id'].'">buy</a>';
	
	

	
	

	
	
$picture '<img src="'.$image.'" alt="">';
	
	

	
	
echo 
"<center><table width='85%' border='2' >
	
	

	
	
<tr><td>
$picture </td> <td><h3>$name</h3> <pre>$description </pre> </td><td>Rent $rent_price </td> <td> $add $add1 </td></tr>
	
	

	
	
</table></center>"
;
	
	
	

	
	

	
	
}
	
}
}


function 
cart() {

	
$sub "";
	
$sub2 "";
	
$total=""
    
	
foreach(
$_SESSION as $name => $value){
	
	
if(
$value 0) {
	
	
	
if(
substr($name06)=='cart2_'){
	
	
	
	
$id substr($name6, (strlen($name)-6)); // allows is to take the exact number from cart_
	
	
	
	
$get mysql_query('SELECT id, name, rent FROM movies WHERE id='.mysql_real_escape_string((int)$id) ); // int means interger is only being passed for secuirty;
	
	
	
	
while (
$get_row mysql_fetch_assoc($get) ){
	
	
	
	
	
$sub $get_row['rent']*$value;
	
	
	
	
	
echo 
$get_row['name'].' x '.$value.'@ &euro;'.number_format($get_row['rent'], 2).'= &euro;'.number_format($sub,2).'<a href="cart2.php?remove='.$id.'">[-]</a> <a href="cart2.php?addrent='.$id.'">[+]</a> <a href="cart2.php?delete='.$id.'">[Delete]</a> <br/>  ';
	
	
	
	

	
	
	
}

	
	
	
}

	
	
	
if(
substr($name06)=='cart2_'){
	
	
	
	
$id substr($name6, (strlen($name)-6)); // allows is to take the exact number from cart_
	
	
	
	
$get mysql_query('SELECT id, name, buy FROM movies WHERE id='.mysql_real_escape_string((int)$id) ); // int means interger is only being passed for secuirty;
	
	
	
	
while (
$get_row mysql_fetch_assoc($get) ){
	
	
	
	
	
$sub2 $get_row['buy']*$value;
	
	
	
	
	
echo 
$get_row['name'].' x '.$value.'@ &euro;'.number_format($get_row['buy'], 2).'= &euro;'.number_format($sub2,2).'<a href="cart2.php?remove='.$id.'">[-]</a> <a href="cart2.php?addbuy='.$id.'">[+]</a> <a href="cart2.php?delete='.$id.'">[Delete]</a> <br/>  ';
	
	
	
	

	
	
	
}

	
	
	
}
	
	
	

	
	
	
$total += ($sub+$sub2);
	
	
}
	
}
	

	
if(
$total==0){
	
	
echo 
"Your cart is empty";
	
}else{
	
	
}
?>








6
Got it working very simple actually i just added the javascript onchange function to the select tag. as follows

Code: [Select]
<center><form action="films5.php" method="POST">
<center>Browes Films: <select name="category"[color=red]onchange='this.form.submit()'[/color] ></center>
<option selected="selected">Choose a Genre...</option>
<option value="Added">All</option>
<option value="Action">Action</option>
<option value="Comedy">Comedy</option>
<option value="Drama">Drama</option>
<option value="Thiller">Thiller</option>
<option value="ScFi">ScFi</option>
</select>
</form>
<form action="films3.php" method="POST">
<input type="text" name="search_name" size="10" />
<input type="Submit" value="Search" name="search" />
</form></center>

Then i changed the isset function to check the select tag, (name="catergory") as folllows

PHP Code: [Select]


[color=red]if( isset( $_POST['category'] )[/color] ){

$dropdownValue $_POST['category'];
	
	

switch( 
$dropdownValue ){

case 
"Action" $query "SELECT name,description,image FROM movies WHERE genre ='Action' ORDER BY id DESC LIMIT $start,$per_page"; break;
case 
"Comedy" $query "SELECT name,description,image FROM movies WHERE genre ='Comedy' ORDER BY id DESC LIMIT $start,$per_page"; break;
case 
"Drama" :  $query "SELECT name,description,image FROM movies WHERE genre ='Drama' ORDER BY id DESC LIMIT $start,$per_page"; break;
case 
"Thiller"$query "SELECT name,description,image FROM movies WHERE genre ='Thiller' ORDER BY id DESC LIMIT $start,$per_page"; break;
case 
"Added" :  $query "SELECT name,description,image FROM movies ORDER BY id DESC LIMIT $start,$per_page"; break;
case 
"ScFi" :   $query "SELECT name,description,image FROM movies WHERE genre ='SC-FI' ORDER BY id DESC LIMIT $start,$per_page"; break;
        default : die( 
"You have entered something that isn't an option in my dropdown" );

        }

        }

7
great thanks for help, i'll try tomorrow.

8
Thanks for reply, i will try the javascript way myself, but  do you have  a simple example i could go use or can you edit my code , i'm just not to sure how to go about it. whenever you have some spare time there's no rush thanks

9
Hi i am using a dropdown list to run different queries. the user selects an option from the list and then hits a submit button. i was just wondering if i could get the dropdown list to work without having to use the submit button? is there an easy to edit my code to acheive this ?

this is the some of the code i am using



<center><form action="films6.php" method="POST">
<center>Browes Films: <select name="category"></center>
<option value="Action" selected="selected">Action</option>
<option value="Comedy">Comedy</option>
<option value="Drama">Drama</option>
<option value="Thiller">Thiller</option>
<option value="Added">New Releases</option>
<option value="ScFi">ScFi</option>
</select>
<input type="text" name="search_name" size="10" />
<input type="Submit" value="Search" name="search" />
</form></center>



PHP Code: [Select]

if( isset( $_POST['search'] ) ){

   
$dropdownValue $_POST['category'];
	
	

   switch( 
$dropdownValue ){

case 
"Action" $query "SELECT name,description,image FROM movies WHERE genre ='Action'   ORDER BY id DESC LIMIT $start,$per_page"; break;
case 
"Comedy" $query "SELECT name,description,image FROM movies WHERE genre ='Comedy' ORDER BY id DESC LIMIT $start,$per_page"; break;
case 
"Drama" :  $query "SELECT name,description,image FROM movies WHERE genre ='Drama' ORDER BY id DESC LIMIT $start,$per_page"; break;
case 
"Thiller"$query "SELECT name,description,image FROM movies WHERE genre ='Thiller' ORDER BY id DESC LIMIT $start,$per_page"; break;
case 
"Added" :  $query "SELECT name,description,image FROM movies ORDER BY id DESC LIMIT $start,$per_page"; break;
case 
"ScFi" :   $query "SELECT name,description,image FROM movies WHERE genre ='SC-FI' ORDER BY id DESC LIMIT $start,$per_page"; break;
default : die( 
"You have entered something that isn't an option in my dropdown" );

        }

        }
	
	

	
	

	
	

	
	
$query_run mysql_query($query);


10
yesss got it to work ;D , just changed the full path to just the image name(name.jpg) in the database and it worked, something so simply.
thanks for all the help guys and advice to store path name in a database instead of the actually image

11
ok checked the image path in the source code it is ok. i am using xammp and phpadmin on my laptop. i stored the images in a folder called images in my websites folder.
using the full path of the image in the database and its stored as a varchar 50 characters,
I'm really clueless on this now. displaying images on a php page through mysql db is by far the hardest thing i've done in php so far cant seem to get it working.

12
Are you storing the entire path or just the filename?

i'm storing the entire path(varchar 50)

13
hi again , i set up a databse with 3 colums (id, name, and image), and i stored the image path in the image column.  the code seems to work but i dont get the image i want, i just get sort of a picture icon instead, anyone any ideas?  the code i'm using is below:

if (isset ($_POST['search_name']) ){
      
$search_name = $_POST['search_name'];
if (!empty($search_name) ){
$query = "SELECT image FROM testimage WHERE name LIKE '".$search_name."%' ";
$query_run = mysql_query($query);
      
if(mysql_num_rows($query_run) >= 1 ){
echo 'results found: ';
while($query_row = mysql_fetch_assoc($query_run) ) {
      
$query_row['image'];
      
$image = $query_row['image'];
      
echo '<img src="'.$image.'" alt="">';

14
thanks for the help , i will try and get some code up and running and let you's know if i do, thanks again

15
its just part of an assignment for college.  do you know how i can fix my problem or can you give me a simple example of what you have suggested

Pages: [1] 2