FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » CLP - ON TOPIC! - Need PHP form email help, Please!
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: CLP - ON TOPIC! - Need PHP form email help, Please! [message #173209 is a reply to message #173194] Sun, 27 March 2011 20:30 Go to previous messageGo to previous message
Tim is currently offline  Tim
Messages: 13
Registered: March 2011
Karma:
Junior Member
In article <imm16p$phv$1(at)speranza(dot)aioe(dot)org>, PStechPaul
<paul(at)pstech-inc(dot)com> wrote:

> "Tim" wrote in message news:260320111732264412%batwzrd(at)hotmail(dot)com...
>
>> $new_profile = $FTGfirstname"_"$FTGlastname".html";
>> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
>
> The first argument of fopen() must be a string.
>
> Here is a portion of your code that I ran through an on-line PHP lint:
> http://www.icosaedro.it/phplint/phplint-on-line.html
>
> with some corrections and additions:
>
> <?php
> #defined dummy function to reduce errors
> /*.string.*/ function DoStripSlashes($rawstr) {
> return "str"; }
>
> $FTGheadshot = $_FILES['headshot']['name'];
> $FTGfirstname = DoStripSlashes( $_POST['firstname'] );
> $FTGlastname = DoStripSlashes( $_POST['lastname'] );
> $FTGaddress = DoStripSlashes( $_POST['address'] );
> $FTGcity = DoStripSlashes( $_POST['city'] );
> $FTGstate = DoStripSlashes( $_POST['state'] );
> $FTGzip = DoStripSlashes( $_POST['zip'] );
> $FTGhomenum = DoStripSlashes( $_POST['homenum'] );
> $FTGmaincontact = DoStripSlashes( $_POST['maincontact'] );
> $FTGcellnum = DoStripSlashes( $_POST['cellnum'] );
> $FTGworknum = DoStripSlashes( $_POST['worknum'] );
> $FTGfaxnum = DoStripSlashes( $_POST['faxnum'] );
> $FTGemail = DoStripSlashes( $_POST['email'] );
>
> # Save image to profiles directory
> $path = "profiles/";
> $path = $path . basename($FTGheadshot);
> if(move_uploaded_file($_FILES['headshot']['tmp_name'], $path)) {
> echo "The file ". basename( $_FILES['headshot']['name']).
> " has been uploaded";//moves file and notifies if successful
> } else{
> echo "There was an error uploading the file, please try again!";//or not
> }
>
> # This was very wrong
> # $new_profile = $FTGfirstname"_"$FTGlastname".html";
>
> # I'm not sure if this works as desired, but it parses correctly
> $new_profile = $FTGfirstname . $FTGlastname . ".html";
>
> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
> ?>
>
> Error report:
>
> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
> \_ HERE
> ==== 30: notice: unhandled error(s): E_WARNING
>
> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
> \_ HERE
> ==== 30: ERROR: undeclared constant `profiles'
>
> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
> \_ HERE
> ==== 30: ERROR: `... / EXPR': found string, expected a number.
>
> $fh = fopen(profiles/$new_profile, 'w') or die("can't open file");
> \_ HERE
> ==== 30: ERROR: `exit()' (aka `die()') isn't a function, it is a statement.
> Trying to continue anyway, but probably the result of the expression will be
> of the wrong type.
>
> I'm not a PHP expert, but I caught the fopen error without using the lint
> utility. And the lint utility gave some very good hints that I did not know,
> such as how to declare a function return value as string.
>
> Paul
>
>
>
Paul, thanks for that link, I will try it out.

Sadly, even I found several errors while cutting and pasting the code
here. Here are some of the changes I have made. I am still working on
it but I think this is closer.

$page_name = $FTGfirstname . $FTGlastname . ".html";

$string1 = "<html>\n
..<head>\n
..<title>$page_name</title>\n
..</head>\n
..<body>\n";
$string2 = "<table width=\"800\" border=\"1\" cellspacing=\"2\"
cellpadding=\"10\"><tr>\n";
$string3 = "<td>firstname : $FTGfirstname<br />\n
..lastname : $FTGlastname<br />\n
..address : $FTGaddress<br />\n
..city : $FTGcity<br />\n
..state : $FTGstate<br />\n
..zip : $FTGzip<br />\n
..homenum : $FTGhomenum<br />\n
..maincontact : $FTGmaincontact<br />\n
..cellnum : $FTGcellnum<br />\n
..worknum : $FTGworknum<br />\n
..faxnum : $FTGfaxnum<br />\n
..email : $FTGemail<br /></td>\n";
$string4 = "<td><img src=$FTGheadshot /><br /></td></tr></table>\n";
$string5 = "<table width=\"800\" border=\"1\" cellspacing=\"2\"
cellpadding=\"10\"><tr><td>\n";

$new_profile = "profiles/$page_name";
$fh = fopen($new_profile, 'w') or die("can't open file");
fwrite($fh, $string1);
fwrite($fh, $string2);
fwrite($fh, $string3);
fwrite($fh, $string4);
fwrite($fh, $string5);

Is this right? $new_profile = "profiles/$page_name";

I've seen it done that way but it just seems wrong. I guess I could put
everything in one string, as the original did, but it seemed so long I
wanted to break it up.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ip address of client
Next Topic: Islandnet.com dropping support for PHP4
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 21:40:19 GMT 2024

Total time taken to generate the page: 0.04999 seconds