Omnimaga

General Discussion => Technology and Development => Web Programming and Design => Topic started by: flyingfisch on June 14, 2012, 08:58:27 pm

Title: PHP question
Post by: flyingfisch on June 14, 2012, 08:58:27 pm
OK, having a problem with PHP.

Here is the code i have:

Code: [Select]
<select name="formSelect">
<option value="value1">value1</option>
<option value="value2">value2</option>
</select>

<form action= "<?PHP echo "upload.php?" . $_POST["formSelect"]) ?>" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="userfile" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>

And its not working.

What I want it to do is make the form action equal upload.php?formSelectvalue .

Can anyone help?

EDIT:

Fixed it by putting <select> inside the <form> tags
Title: Re: PHP question
Post by: Deep Toaster on June 14, 2012, 09:48:15 pm
Your problem is the line <?PHP echo "upload.php?" . $_POST["formSelect"]) ?> in line 6. Unmatched right paren.
Title: Re: PHP question
Post by: Sorunome on June 15, 2012, 10:38:52 am
That parentheses must be a semicolon.
Title: Re: PHP question
Post by: flyingfisch on June 18, 2012, 12:23:57 pm
I have another question now.

This code should tell users to go to the new domain name, only if the domain name is not the new one.

Instead it displays it all the time.

Code: [Select]
<?PHP
$domain_name = $_SERVER['HTTP_HOST'];

if ($domain_name != "newdomain.com" || $domain_name != "www.newdomain.com") {
   echo "<p>We have a new domain name! <a href="newdomain.com">Click Here!</a></p>"
}
?>
Title: Re: PHP question
Post by: Sorunome on June 18, 2012, 12:42:38 pm
if ($domain_name != "newdomain.com" || $domain_name != "www.newdomain.com")
->
if ($domain_name != "newdomain.com" && $domain_name != "www.newdomain.com")
Title: Re: PHP question
Post by: flyingfisch on June 18, 2012, 12:52:50 pm
Oh, oh, ok. I was getting mixed up. I was thinking I needed to use "or".