If command Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wee493
Forum Newbie
Posts: 22
Joined: Sat Sep 06, 2008 3:05 pm

If command Help

Post by wee493 »

I'm trying to get this if command working. There is a text form that can be entered but doesnt have to be. If it is not entered than a random string will replace it. Similar to the one that http://tinyurl.com might use where u dont have to enter a custom url but u can.

Code: Select all

 
$alex = 'newurl';
 
if($alex = "")  { 
$rnd_url = $newurl;
}
That is the Sniplet

If you need the full code...

Code: Select all

$alex = 'newurl';
 
if($alex = "")  { 
$rnd_url = $newurl;
}
 
if ($_POST['submit']) {
$rnd_url=chr(rand(97,122)).chr(rand(97,122)).chr(rand(97,122)).chr(rand(97,122)); // Later Add .rand(111,999)
$newurl = $_POST['newurl'];
$oldurl = $_POST['oldurl'];
$title= $_POST['title'];
$urlcloking= $_POST['urlcloking'];
$redirect = "<html><head><title>$title</title></head><body>
<iframe src='$oldurl' height='100%'  width='100%' frameborder='0'>
</script></body></html>";
 
if(file_exists("$newurl/index")) die("Please try again there was an error.");
mkdir("$newurl");
 
$filename = "$newurl/index";
$filename .= ".php";
$Content = "<META http-equiv='refresh' content='0;URL=$oldurl'>";
$handle = fopen($filename, 'x+');
fwrite($handle, $Content);
fclose($handle);
?>
<br>
</span>
<h2 class="style1"><marquee>Success!</marquee></h2>
<span class="style2">Your new URL is <a href=http://wiurl.com/<?php echo "$newurl"; ?>>http://wiurl.com/<?php echo"$newurl"; ?></a><br />
Copy your URL <input type="text" class="text" id="chi2" size="18" value="http://wiurl.com/<?php echo "$newurl"?>" onclick="this.select();" />
<?php
User avatar
Ziq
Forum Contributor
Posts: 194
Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh

Re: If command Help

Post by Ziq »

Code: Select all

if($alex = "")  {
always true.
If you want to check a $alex variable, you should use a empty() function

Code: Select all

 
if(empty($alex))  {
 
or (this code may generate a notice warning)

Code: Select all

 
if($alex == "")  {
 
= - attribution, == - compare
Post Reply