Jump to content

TextBox coding in need of help


borden0108

Recommended Posts

Hi all

 

i have been trying for 6 hours to write some code that will show a text box and the user puts in there id then it provides a link with the id in the middle of it

 

so say the id is 111555

 

the link is http://example.com.au/data/users/111555/2011/1/1 i want the user to insert their id and do if the id 343034 the link is

http://example.com.au/data/users/343034/2011/1/1

 

can any one give me the code to this i have gotten no where

from tutorials

               

please matt                                       

Link to comment
Share on other sites

<?php

$url1 = 'http://example.com.au/data/users/';
$url2 = '/2011/1/1';

if (isset($_GET['id']))
{
echo $url1 . $_GET['id'] . $url2;
}
else
{
echo '
	<form method="get" action="">
		Enter ID <input type="text" name="id">
		<input type="submit" value="Get URL">
	</form>';
}

?>

Link to comment
Share on other sites

<?php
if (isset($_POST['link']) && $_POST['link']!='') {
    $link=$_POST['link'];
    header("Location: http://www.example.com.au/data/users/$link/2011/1/1");
    exit;
}
?>
Enter User ID:-<br/>
<form method="post" action="" name="linkID'>
<input type="text" name="link" size="20" /><br/>
<input type="submit" name="submit" value="Submit Link" />
</form>

 

really you should have some validation with that so users dont enter any one elses ID's but I dont really know what your doing with this.

Link to comment
Share on other sites

php code needs to be uploaded to your server you cannot preview it in your browser without uploading it to your server first, php is read by the server and then outputs html code to the users browser based on the processed code,

if yo just open a php page directly on your computer then it will only show the source code as no server has processed it.

Once you upload it to your web server and then look at the page you will only see the form the code outputs and not the php.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.