473,383 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How do I make a selection of a drop down menu in another page?

I need people to go through a table of courses and when they find the course they want, they can click a "submission" or "registration" button which will automatically take them to the registration form (another php page) where they can fill in their details to be emailed to us, and have the course already selected from a drop-down menu that holds all courses.

How do I do that using javascript or html or php?

I don't have MYSQL, databases, or sessions so security is not a big issue, and my programming skill is not that great so please tell me exactly what I need to write, and what variables should I be substituting in the code.
Sep 4 '10 #1
3 1069
kovik
1,044 Expert 1GB
You don't have a database, yet you are making an application with courses? Are you serious?

Anyway, if you WERE using a database, every course would have a unique ID. When someone registers, they could either have that course already selected from a <select> element using that ID, or they wouldn't need a <select> element at all since you already sent the ID to the form.


Course page:
Expand|Select|Wrap|Line Numbers
  1. <h1>Course #XXX: Course Name<h1>
  2. <p>Course details...</p>
  3. <p>Would you like to register for this course?</p>
  4. <a href="register.php?id=XXX">Register</a>

Registration page:
Expand|Select|Wrap|Line Numbers
  1. <?php $errors = array();
  2. $success = false;
  3.  
  4. if (!empty($_POST) && isset($_GET['id'])) {
  5.   // Validate form data
  6.   if (empty($_POST['name'])) {
  7.     $errors[] = 'Name must be filled.';
  8.   }
  9.  
  10.   // Sign up user
  11.   if (empty($errors)) {
  12.     $name = $_POST['name'];
  13.     $course = $_GET['id'];
  14.     // Save the user's registration via the above information
  15.     // Then e-mail it to whoever cares
  16.     $success = true;
  17.   }
  18. } ?>
  19.  
  20. <?php if ($success): ?>
  21. <p class="success">You are now registered for course #<?php echo $_GET['id']; ?>.</p>
  22. <?php else: ?>
  23. <?php if (!empty($errors)): ?>
  24. <p class="errors">Errors: <?php echo implode("<br />\n", $errors); ?></p>
  25. <?php endif; ?>
  26. <form method="post">
  27.   <label for="name">Name:</label>
  28.   <input type="text" name="name" />
  29.   <button type="submit">Register</button>
  30. </form>
  31. <?php endif; ?>
Sep 4 '10 #2
Thanks for this.

Yes I am using a simple array to hold the courses list in the registration form. It already has validations and the array built in.

How would I do this?
Sep 4 '10 #3
kovik
1,044 Expert 1GB
If the courses are in an array, then their "ID" would be their array key. Then, just apply the code I provided.
Sep 4 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Greg Scharlemann | last post by:
I am attempting to populate a drop down menu based on the selection of a different drop down menu. However, it is not working correctly, I cannot figure out for the life of me what exactly happens...
1
by: Greg Scharlemann | last post by:
I would like to automatically populate a drop down menu when the page loads based on the selection of an item in a different drop down menu. I made a test page that when drop down #1 changes, drop...
11
by: Dan | last post by:
Hello all, I am getting records from a db and displaying the records to the user through a drop down menu in an asp page. Each record has 6 fields and I need to display them all to the user in...
2
by: mjeassoc | last post by:
I have a fairly simple page serving as a portfolio. It is a long page, with narrative and large thumbs which link to other pages, larger photos, pdf files, etc. Near the top of the page, I have...
3
by: rsteph | last post by:
I have a javascript drop down menu that I borrowed from a website. It utilizes a little .css to help with formatting. The menu works great, and on all 3 of the browsers I'm concerned about; but I am...
2
by: ponyeyes | last post by:
Hi There, I am a bit of a newbie to PHP programming and I would like to know how I can place a selected drop down option into a PHP variable and then produce an sql query which incorporates this...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
4
by: cctxman1942 | last post by:
Here is what I have done: Created a page with a drop down menu listing names of builders retrieved from a mysql database containing contact info for client builders. What I need to do, and so far...
6
by: phpnewbie26 | last post by:
My current form has one multiple select drop down menu as well as few other drop down menus that are single select. Originally I had it so that the multiple select menu was first, but this created...
0
by: fatroshi | last post by:
Hi, I´m trying to create a simple application with a drop menu. The drop menu should load a page inside the same page. Same as the php inlude("path") function. I´ve find one way to create...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.