Help with PHP.
#1

Hello. I wanted to make Submit button and when press, it redirects to url (eg: hostname.com/users.php?name=submited text

But i don't know how to redirect to this link. I was trying a lot of ways but noone worked.

I do this on submit page:
PHP код:
<html><head>Single-button form</head>
<
body>
<
form action="mydomain/serveronline.php" method="post"Enter a number: <input type="text" name="number" size="3"> <br>
<
input type="submit" name="submit"> </form>
</
body>
</
html
Then on mydomain/serveronline.php:
PHP код:
<?php
if ($_POST['submit'])
{
    
header('Location: http://www.mydomain.com/blog.php?name=. $_POST['number']');
}
?>
But i get this:
Parse error: syntax error, unexpected T_STRING in /home/mindauga/domains/mydomain.com/public_html/serveronline.php on line 4
Reply
#2

1. It's not php support site.
2. Try this:
Код:
header('Location: http://www.mydomain.com/blog.php?name='.$_POST['number']);
Reply
#3

Warning: Cannot modify header information - headers already sent by (output started at /home/mindauga/domains/mydomain.com/public_html/serveronline.php:1) in /home/mindauga/domains/mydomain.com/public_html/serveronline.php on line 4
Reply
#4

Where you placed that code. You can't just drop the header code in the middle of your code.
Reply
#5

PHP код:
<?php
if ($_POST['submit'])
{
    
header('Location: http://www.mydomain.com/blog.php?name='.$_POST['number']);
}
?>
This all what i have on serveronline.php
Reply
#6

Finally i have done this...

PHP код:
<?php
if ($_POST['submit'])
{
$text1 $_POST['number'];
echo 
$text1;
$text2 "<script language='javascript'>window.location.href='/blog.php?name=$text1'</script>";
echo 
$text2;
}
?>
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)