Jump to content

small search function

Whether you're a seasoned veteran or a struggling beginner, Web Radiance is the web development and web design forum for you. You'll find answers to all your HTML, CSS, SEO, and Programming needs. Pull up a chair and stay awhile.

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • This topic is locked

small search function Rate Topic: -----

#21 User is offline   benbacardi 

  • Administrator
  • Group: Administrators
  • Posts: 1,140
  • Joined: 06-April 06
  • Gender:Male
  • Location:United Kingdom

Posted 21 April 2007 - 01:05 PM

Use this PHP:

<?php if (isset($_GET['buy'])) {
echo 'Thank you!';
} ?>

0

#22 User is offline   martin leblanc 

  • W.R. Private
  • Group: Members
  • Posts: 4
  • Joined: 21-April 07

Posted 22 April 2007 - 02:32 AM

View Postbenbacardi, on Apr 19 2007, 02:18 PM, said:

What's the search box called? I think they'd have to be seperate querys per table but I'm not sure, for example:

ALBUM RESULTS:
(then list results of "SELECT * FROM music_albums WHERE prod_name LIKE '%".$_POST['seach']."%' OR prod_artist LIKE '%".$_POST['search']."%'" )

SINGLE RESULTS:
etc

Where $_POST['search'] is the reference to whatever the user typed in


'%".$_POST['seach']."%' ... is a security issue bacuse it allows SQL-injection :-/

Also do some checking on a variable like that instead of just placing it in the SQL.
0

#23 User is offline   benbacardi 

  • Administrator
  • Group: Administrators
  • Posts: 1,140
  • Joined: 06-April 06
  • Gender:Male
  • Location:United Kingdom

Posted 22 April 2007 - 02:48 AM

Actually, with the latest versions of PHP, PHP automatically escapes any charactors that can be used for SQL injection, so avoiding that issue
0

#24 User is offline   martin leblanc 

  • W.R. Private
  • Group: Members
  • Posts: 4
  • Joined: 21-April 07

Posted 22 April 2007 - 05:51 AM

View Postbenbacardi, on Apr 22 2007, 07:48 AM, said:

Actually, with the latest versions of PHP, PHP automatically escapes any charactors that can be used for SQL injection, so avoiding that issue

I wouldn't rely too much on the security built in PHP!
0

#25 User is offline   Man2u2uk 

  • W.R. Lieutenant
  • Group: Members
  • Posts: 396
  • Joined: 14-April 07
  • Gender:Male

Posted 22 April 2007 - 08:03 AM

<?php if (isset($_GET['buy'])) {
echo 'Thank you!';
} ?>


i am guessing i would put this at the top of each page that i use the "Add" button on?

but i think i will have a problem as i have built my shop using case statements to load each page.

and i have set it to always default to index.php, so would the echo still work?

Thanks.
0

#26 User is offline   Ben Abrams 

  • The buddy system:never fails
  • Group: Administrators
  • Posts: 1,850
  • Joined: 04-April 06
  • Gender:Male

Posted 22 April 2007 - 08:58 AM

View PostMan2u2uk, on Apr 21 2007, 06:55 PM, said:

Woot works like a dream :)

the following code:

<? echo '<a href ="'.$_SERVER['PHP_SELF'].
'?buy='.$i.'">Add</a>';?> </div>


places the word "Add" next to each procuct, when "Add" is clicked it adds the product to my basket which works fine...

how can i get it so that after clicking on "Add" it will display a message saying "You have just added (item) to you cart"

explain what you mean? the link could simplt link back to a page that says product added, and then refreshes you back to the last page (like how it does on webradiance, when you do a search)

View PostSirkent, on 21 September 2007 - 04:26 AM, said:

<monty python high-pitched female voice>I DON'T LIKE SPAM!</monty python high-pitched female voice>
0

#27 User is offline   Man2u2uk 

  • W.R. Lieutenant
  • Group: Members
  • Posts: 396
  • Joined: 14-April 07
  • Gender:Male

Posted 24 April 2007 - 05:46 AM

Well at the moment, when i click add it takes me back to the shops home page. really i would like it to say

"You have just added (Item Name Goes Here) to your shopping cart" and then either take them back to the home page.

or give them the option to carry on shopping or goto the checkout
0

#28 User is offline   benbacardi 

  • Administrator
  • Group: Administrators
  • Posts: 1,140
  • Joined: 06-April 06
  • Gender:Male
  • Location:United Kingdom

Posted 24 April 2007 - 06:50 AM

In my shopping cart site, the Add to Basket button links to a page (addbasket.php) which takes a GET arguement of the ID to be added, adds that ID, then redirects to the basket page...

For example:

viewproduct.php?id=12 ---> addbasket.php?id=12 -- > viewbasket.php
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users