Form Mail checking image size<

liunx

Guest
I decided to start a new thread about this, because it is no longer checking the size of an attatchment, or sending an attatchment.

Anyway, what I'm trying to do is get it to check the size of an image by the URL entered. It sends the mail just fine, but it does practically nothing with the getimagesize function. When I enter an image that is larger than 100x100, I get these errors.


Warning: getimagesize(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/gag/public_html/gagcontact.php on line 76

Warning: getimagesize(<!-- m --><a class="postlink" href="http://joshhttp://joshmccrain.com/layout/squarelogo2.jpg">http://joshhttp://joshmccrain.com/layou ... elogo2.jpg</a><!-- m -->): failed to open stream: Permission denied in /home/gag/public_html/gagcontact.php on line 76
Thank you for sending mail.

But it still sends the mail.

I also want it to include a default image if nothing is specified.

Here's my code


<?php
if (!isset($HTTP_POST_VARS['submit']))
#if submit doesn't have a value
{
?>
<form method="post" name="emailform" action="<?php echo $_SERVER['SCRIPT_NAME']?>" onSubmit="return validateForm(this);">
<p>Game Name:
<input type="text" name="gamename" style="background:#ccc;" /></p>
<p>Real Name(first name is OK):
<input name="realname" type="text" style="background:#ccc;" value="">
</p>
<p>Age:
<input type="text" name="age" style="background:#ccc;" /></p>
<p>
<p title="It is OK to enter N/A if you don't want this to be public.">Email:
<input type="text" name="email" style="background:#ccc;" />
</p>
<p>AIM Name:
<input name="aimname" type="text" style="background:#ccc;" value="" />
</p>
<p>Location(State):
<input name="state" type="text" style="background:#ccc;" value="" />
</p>
<p>Favorite TDM Map:
<input name="tdm" type="text" style="background:#ccc;" value="" />
</p>
<p>Favorite Obj. Map:
<input name="obj" type="text" style="background:#ccc;" value="">
</p>
<p>Favorite Weapon:
<input name="favweapon" type="text" style="background:#ccc;" value="" />
</p>
<p>2nd Favorite Weapon:
<input name="ndfavweapon" type="text" style="background:#ccc;" value="">
</p>
<p>Hobbies:
<textarea name="hobbies" style="background:#ccc;"></textarea>
</p>
<p>Signature Image URL:
<input name="image" type="text" style="background:#ccc;" /> Enter your signature image URL here. The image must be less than or equal to 100x100 pixels. If no image is supplied then we will give you a default image.
</p>
<p title="For example, Call of Duty, Generals">Other Games Played:
<textarea name="othergames" style="background:#ccc;"></textarea>
</p>

<p><input type="submit" name="submit" value="Submit" style="border:1px solid black; color: blue; font-family:arial; background:#ccc;" /></p>
</form>
<?php
}
else
{
if($image!=NULL){
$size = getimagesize($image);
if ($size[0] > 100 AND $size[1] > 100){
echo 'Your image is too large, it must be 100x100.';
exit;
}
}
else {
$image = 'http://www.guts-and-glory.net/index/themes/subBlack3d/forums/images/logo.gif';
}

$gamename = stripslashes($HTTP_POST_VARS['gamename']);
$realname = $HTTP_POST_VARS['realname'];
$email = $HTTP_POST_VARS['email'];
$aimname = $HTTP_POST_VARS['aimname'];
$state = stripslashes($HTTP_POST_VARS['state']);
$tdm = $HTTP_POST_VARS['tdm'];
$obj = $HTTP_POST_VARS['obj'];
$favweapon = $HTTP_POST_VARS['favweapon'];
$ndfavweapon = $HTTP_POST_VARS['ndfavweapon'];
$hobbies = stripslashes($HTTP_POST_VARS['hobbies']);
$age = stripslashes($HTTP_POST_VARS['age']);
$image = stripslashes($HTTP_POST_VARS['image']);
$othergames = stripslashes($HTTP_POST_VARS['othergames']);
$to = "GaG<[email protected]> ";

if (($gamename!=NULL)||($realname!=NULL)||($image!=NULL)||($email!=NULL)||($aimname!=NULL)||($state!=NU LL)||($tdm!=NULL)||($obj!=NULL)||($favweapon!=NULL)||($ndfavweapon!=NULL)||($hobbies!=NULL)||($posit ion!=NULL)||($othergames!=NULL)||($age!=NULL))
#check if a real email address, if it returns true it sends the email
#also checks to make sure the comment and name fields aren't empty
{
# subject
#$subject = "mail from site" deleted

# message
$message = '
<html>
<head>
<title>$gamename</title>
<style type="text/css">
body { font-family: arial; background: #ccc; }
.section { font-size:12pt;font-weight:bold;color:blue; }
</style>
</head>
<body>

<span class="section">Game Name:</span> '.$gamename.'<br /><br />
<span class="section">Real Name:</span> '.$realname.'<br /><br />
<span class="section">Email:</span> '.$email.'<br /><br />
<span class="section">AIM Name:</span> '.$aimname.'<br /><br />
<span class="section">State:</span> '.$state.'<br /><br />
<span class="section">Favorite TDM Map:</span> '.$tdm.'<br /><br />
<span class="section">Age:</span> '.$age.'<br /><br />
<span class="section">Favorite Objective Map:</span> '.$obj.'<br /><br />
<span class="section">Favorite Weapon:</span> '.$favweapon.'<br /><br />
<span class="section">Favorite Weapon:</span> '.$ndfavweapon.'<br /><br />
<span class="section">Link to Image:</span> '.$image.'<br /><br />
<span class="section">Second Favorite Weapon:</span> '.$ndfavweapon.'<br /><br />
<span class="section">Hobbies:</span> '.$hobbies.'<br /><br />
<span class="section">Other Games Played:</span> '.$othergames.'<br /><br />

</body>
</html>
';

$headers = "MIME-Version: 1.0\r\n"; #headers
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";


$headers .= "From: $email\r\n"; #The sender's email
#Will show up in your box from their email address


mail($to,$gamename,$message,$headers);

echo 'Thank you for sending mail.';
} else {
echo 'Sorry, one of more of your fields is invalid.';
}
}
?>ugg not this again :P

ok, it should work, but look at the url you used

<!-- m --><a class="postlink" href="http://joshhttp//joshmccrain.com/layout/squarelogo2.jpg">http://joshhttp//joshmccrain.com/layout/squarelogo2.jpg</a><!-- m -->

look closely :)Hey! It does work!

Now I just have to figure out how to get it so it will allow one field to be blank in my initial javascript check...why one field? and it sounds like a client side issue now :)Hehe, it was, check the clientside forum :)

But...i'm having a php issue now. If you leave the field blank it's supposed to include that default url. But it doesn't, it just leaves it blank.

Any idea why?because you overwrite it here

$image = stripslashes($HTTP_POST_VARS['image']);

move that up to the if statment to check for NULL.hmm...OK. Something like this?


else {
$image = 'http://www.guts-and-glory.net/index/themes/subBlack3d/forums/images/logo.gif';
$image = stripslashes($HTTP_POST_VARS['image']);
}no cause you are still overwriting it.


if($image!=NULL){
$size = getimagesize($image);
if ($size[0] > 100 AND $size[1] > 100){
echo 'Your image is too large, it must be 100x100.';
exit;
}
$image = stripslashes($HTTP_POST_VARS['image']);
}
else {
$image = 'http://www.guts-and-glory.net/index/themes/subBlack3d/forums/images/logo.gif';
}

and then delete it down form below
 
Back
Top