Viewing Id from URL on Page
#1
Hi,
I am in the process of writing a script, and I would like some assistance with a problem I am having. Here is a sample URL suffix from my script:
/index.php?id=12

I would like the id number to show up on the page. So if a user goes to /index.php?id=412, the only thing that would show up on the screen is the number "412".

Is there an easy way to accomplish this? Thanks in advance, I really appreciate it! Smile
Reply
#2
This value should be stored in the variable $mybb->input['id'], so echoing that variable should output the id to the screen. Wink
Reply
#3
musicalmidget Wrote:This value should be stored in the variable $mybb->input['id'], so echoing that variable should output the id to the screen. Wink
Hi,
Thanks for your reply!

Sorry, I should have been more specific. As of right now, this php file has nothing to do with MyBB, so it isn't connected to any templates or variables. I plan on getting the stand-alone php file to work, and then integrating with MyBB later on.
Reply
#4
No worries.

In that case, you should be able to use $_GET['id'] instead.
Reply
#5
musicalmidget Wrote:No worries.

In that case, you should be able to use $_GET['id'] instead.
Thanks, worked like a charm! Smile
Reply
#6
Added:
I've been looking for a good beginners guide to php book, can you recommend one? I really should start working on learning more php! Smile

Thanks again!
Reply
#7
I used a book called "PHP and MySQL for Dummies" a few years ago to kick start learning, although it's proobably very much out of date now unless a newer version has been released since then. There seem to be many different PHP books available now.

Most of my experience came from studying the code of existing scripts though, including MyBB. Also, PHP is very well documented, so the manual came in very handy at times (and still does to be honest Toungue).
Reply
#8
musicalmidget Wrote:I used a book called "PHP and MySQL for Dummies" a few years ago to kick start learning, although it's proobably very much out of date now unless a newer version has been released since then. There seem to be many different PHP books available now.

Most of my experience came from studying the code of existing scripts though, including MyBB. Also, PHP is very well documented, so the manual came in very handy at times (and still does to be honest Toungue).
Thanks, I'll have to take a look into the Dummy Php Book (I used a Dummy book to learn HTML, so I know those work! Big Grin).

I am also reading a lot over at W3Schools, and that helps a lot!

Thanks again! Big Grin
Reply
#9
I was doing some more PHP coding and another question came up. Its a pretty simple question, concerning the $_GET['id'] and using it in a form field.

I would like the $_GET['id'] inserted into a hidden form field as the value. Is there an easy way to do this?

Thanks again for your help!
Reply
#10
<input type="hidden" name="name" value="<?php echo $_GET['id']; ?>" />

If the above hidden field is submitted with a form then the recieving page will have the value of $_POST['name'] or $_GET['name'] (depending on the method used) asigned to the value that was $_GET['id'] on the form page.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)