logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > General
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 08-24-2007, 01:00 AM   #1
nanny
 
Join Date: Apr 2006
Posts: 290
Default php session + get info from database then show form?

Hi I have the sessions working well. What I am trying to accomplish is this:
As admin I will be submitting a lot of listings online at first to get the ball rolling.
A person then wants to edit their listing without logging in so they click the link "Update Listing"
This takes them to a form that collects their name and telephone number and if it is a match it will show the form to be edited.
Now I can get it to say their name and a form conditionally show within the session but the listing id is not carrying through to show the edit form?
Any suggestions? I have tried session and get but maybe a go to detail link is needed prior to the form showing. Is this true?

On completion of this form it will have a hidden variable to make the status not active again, as it would be active. I would then receive an email and see the listing before approving it to be active again.
I thought about just having the form and email it to me but that is double work - this way I can check and click.
nanny is offline   Reply With Quote
Old 08-24-2007, 09:15 AM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

append the ID to the form action

PHP Code:
action="process_form.php?id=$id
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 08-24-2007, 10:11 AM   #3
nanny
 
Join Date: Apr 2006
Posts: 290
Default

I got it working I simply had the unset session attached and for some reason it wouldn't work, so I removed it.
I am needing to however match two items in the database.
i can check them individually before continueing on with the session but I have found that I really need to check both match the same id
I am checking for a business name and a telephone number.
If someone gives a business name from id number 4 and a telephone number from id number 6 the session still continues because it starts from the business name.
How to repair this fault, should I do a session array or use
Code:
if ($_POST['businessname'] && $_POST['tel'] == $_POST['id']) { unset $error array() };
Not sure if I am doing this right. I tend to complicate things sometimes, but I am willing to learn...
nanny is offline   Reply With Quote
Old 08-24-2007, 10:40 AM   #4
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

is the ID the telephone number?

here you are comparing the two vars

$_POST['tel'] == $_POST['id']
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 08-25-2007, 12:46 AM   #5
nanny
 
Join Date: Apr 2006
Posts: 290
Default

Hi davidj
No the id of the table is separate to the telephone field and the businessname field.
But I am wanting the same telephone & business field to be searched for the same id in the table otherwise it is all over the place.
nanny is offline   Reply With Quote
Old 08-25-2007, 12:49 AM   #6
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

Quote:
But I am wanting the same telephone & business field to be searched for the same id in the table otherwise it is all over the place.
please read this back to yourself as this doesnt make sense
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 08-25-2007, 12:56 AM   #7
nanny
 
Join Date: Apr 2006
Posts: 290
Default

OK I will go back to the beginning.
It is a session and in the first form for the user to fill out.
1: Business name
2: Telephone number
These are meant to match to the corresponding id of the listing.
At the moment I can place Business name for Suji Store and the telephone for Mick's Store and it will continue on the session and show the link to detail for the business name.
For a little extra security, I want the Business name for Suji Store and the Telephone for Suji Store to go together - i.e. the same listing id not just by the business name or there is no point in having two questions in the form.
Hope that makes sense.
Thanks.
nanny is offline   Reply With Quote
Old 08-25-2007, 04:23 AM   #8
nanny
 
Join Date: Apr 2006
Posts: 290
Default

O.K
this is my code so far for error checking:
PHP Code:
session_start();
$_SESSION['classbusinessname'] = $_POST['classbusinessname'];
if (
array_key_exists('Continue'$_POST)) {
$classbusinessname trim($_POST['classbusinessname']);
 if (empty(
$classbusinessname)) {
$error['classbusinessname'] = 'Enter business name';
 }
 
$LoginRS__query "SELECT classbusinessname, tel FROM listingf WHERE classbusinessname='" $classbusinessname "' ";
  
mysql_select_db($database_config$config);
  
$LoginRS=mysql_query($LoginRS__query$config) or die(mysql_error());
  
$loginFoundUser mysql_num_rows($LoginRS);
  
//if there is a row in the database, the username was found - can not add the requested username
  
if($loginFoundUser == 0){
    
$error['classbusinessname'] = "$classbusinessname can not be found. Please contact SalonSpa.";
  }
  
$tel trim($_POST['tel']);
 if (empty(
$tel)) {
$error['tel'] = 'Enter phone number';
 }
 
$LoginRS__query "SELECT classbusinessname, tel FROM listingf WHERE tel='" $tel "'";
  
mysql_select_db($database_config$config);
  
$LoginRS=mysql_query($LoginRS__query$config) or die(mysql_error());
  
$loginFoundUser mysql_num_rows($LoginRS);
  
//if there is a row in the database, the username was found - can not add the requested username
  
if($loginFoundUser == 0){
    
$error['tel'] = "$tel can not be found. Please contact SalonSpa.";
  }
  if (!isset(
$error)) {     
header('Location: update_f.php');
  exit;
  
$_POST = array();
}
  } 
I am not getting the two to match, i.e. businessname and tel from listingf

Any suggestions??
nanny is offline   Reply With Quote
Old 08-25-2007, 09:34 AM   #9
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

what does this do???

PHP Code:
$_POST = array(); 
as its inside the condition which EXIT's it wont run???

i cant see anything wrong with it other than your code layout is messy.

you have your tel and businessname checks apart from each other. and your using DW recordsets which im disapointed at.

Quote:
1: Business name
2: Telephone number
These are meant to match to the corresponding id of the listing.
im still not sure what you want

as above you state 'name' and 'number' must match the ID? do they match the ID together as a string?
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:05 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com