Hello to all PHPers!
I have just started learning this amazing coding language and I need some help with one particular task i have now.
I need a kind of solution or at least an idea how to do the following:
There is an existing URL link generated dinamicaly by a server. At the end of this link a number (6 digits) that can be changed. I can put any number at the end of this given URL to extract some particular details as every number is associated with its records in a database.
Due the fact that I don't have any access to a database that can accept a number and post a HTML page based on that request I have to get a way around it to automate some processes.
I've come up with this and not sure if it possible to implement in either PHP or CGI:
1. integrate a given URL into a script in the way it could accept a 6 digit number from front PHP interface.
2. create request field for this 6 digit number on existing HTML page.
3. Once the number is entered and proccessed the complete URL is run and generate a responce in HTML.
Expected results: An entered 6 digit number will be attached to an URL by PHP script and the result posted as normal HTML page.
I'd appreciate if someone could advise if it is possible to do and direct me to a solution.
Thanks
simple PHP code needed
Moderator: General Moderators
If you don't have database acess, writing to a text file would be your only other option.
you will need to look into fopen() and fwrite()
Then when your PHP script looks at the value of the 6 digit number, you will need to search this text file you've created for the value corresponding with that number.
you will need to look into fopen() and fwrite()
Then when your PHP script looks at the value of the 6 digit number, you will need to search this text file you've created for the value corresponding with that number.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Maybe I've missed something in his post, but I don't think he needs any text files or anything.
Amka, correct me if I'm wrong but what you're saying is that you normally would type in something along the lines of:
Currently you manually change the address in your browser, but you'd like a php page where you can just type in the 6 digits and it automatically adjusts the link and then redirects you to the page with the correct digits?
If I am correct with this, you will need to look into the functions for working with URL's and strings. Hopefully one of the bright guys here can post an example. It might be best if you could post a sample link so we can know what part to change (i.e. is it easy and just replace last 6 digits on link or are the digits somewhere in the middle of the link?).
Amka, correct me if I'm wrong but what you're saying is that you normally would type in something along the lines of:
Code: Select all
http://www.myserver.com/data?id=asdklfjhas&v=GHZps123456If I am correct with this, you will need to look into the functions for working with URL's and strings. Hopefully one of the bright guys here can post an example. It might be best if you could post a sample link so we can know what part to change (i.e. is it easy and just replace last 6 digits on link or are the digits somewhere in the middle of the link?).
Hi,
This is actually pretty easy.
Once the user submits the form, have some code that gets the 6 digit number.
This will take the 6 digit number from a form and add it to the end of a URL, then redirect to that URL.
Note that you'll have to properly validate input and such.
Hope this helps
Sphenn
This is actually pretty easy.
Once the user submits the form, have some code that gets the 6 digit number.
Code: Select all
<?php
$number = $_POST['number'];
$url = "http://www.your-url.com?num=$number";
header("Location: $url");
?>Note that you'll have to properly validate input and such.
Hope this helps
Sphenn