• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Using $GET and $POST with a Mysql table ID

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have only being doing PHP for a few weeks so please excuse me if my question is basic. What I have is a site with a list of jobs on the home page that people can apply for. Each job has its own hyperlink that matches its job_id from the database table. What I am trying to do now is figure out how that ID can be passed to another page that contains a submit form (apply.php). That form would be for jobseekers to fill in their name address etc.. When they hit submit, can it be possible for the MYSQL user table to be inserted as well as insert into the applications table that I have. I have 4 tables.

users jobs categories applications

The applications table is a bridge table between users and jobs and only contains application_id, user_id and job_id.

By inserting into users and applications I will then be able to see who has applied for jobs.

Applications table would need the job_id and user_id adding to it somehow.

I would appreciate it if anybody could advise. Thanks

Rob
 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, your app requires a user to have logged in before applying for jobs right?

When a user logs in, that user's user ID will be known. Store this in the $_SESSION

As for the job application, each record/link has a job ID so it is possible to pass this as a hidden field within a form for post (recommended).

Depending on how many forms/pages from search result to final submission, you need to store this job ID thing throughout. Storing this in the session is not necessary because once the final submission is done, it will be useless. However, putting this in the session is probably the simplest approach. The only bad thing is session may have obsolete/out of scope variables as time goes by without properly clearing.

Just curious is the application ID auto increment in the application table?
 
Rob Nowlan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Yes it is auto increment on applications, users, jobs, categories tables.
The thing here is that jobseekers need to apply without registering. On my home page I have put the jobs into a HTML table with a hyperlink besides each one for "Apply Now", with a while loop to fetch the rows in order to give each job a URL with its job_id e.g. /apply.php?id=4.
This would be for the job with a job_id of 5 from the jobs MYSQL table.
What I am trying to do is use $_GET to pass the id through the html form that I have set up to insert into the users table.
Somehow I need to get the applications table updated with the user_id and job_id for the applicant.
I also think I need to run the users table insert first to create the user_Id and then insert that user_id into the applications table.
How this comes together I am not sure from a php perspective. I cant see it yet.
 
K. Tsang
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Further to my comments earlier, since users can apply without logging in... the apply action does the user registration too because you are inserting record in the user table.

After insert you should able to get that newly inserted row ID for the application table.

The other case you will need to test is when users are logged in! Your link to the apply page will have the user ID in it as well as the job ID.
 
Rob Nowlan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks for the reply. I appreciate it.
My biggest concern at the moment is that I cant get the apply.php code working at all. I cant get GET working to pass the job_id to the form. Users are registering in a way by submitting their details but they are not allowed to log in. Only the one administrator which is already set up.
How can I get the apply.php working?
Thanks
 
Create symphonies in seed and soil. For this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
    Bookmark Topic Watch Topic
  • New Topic