grk101 Posted March 15, 2008 Share Posted March 15, 2008 Hello, Newbie on this forum.. i have done a search, and come up with the follow script, but for some reason i can not get my php email script to write to the cvs file.. Well i can take " name , etc " to pass, but now the values that are entered. I would appreciate any help.. Also is there a way to make this script, so only people on that domain can use it? Much appreciated. <?php session_start();?> <? $to = "test@test.com"; if (!isset($_POST['submit'])) { showForm(); } else { //form submitted $error = 0; if(empty($_POST['imagetext'])) { $error = 1; $errstr[] = "Please validate the image code"; } else { include "securimage.php"; $img = new Securimage(); $valid = $img->check($_POST['imagetext']); if(!$valid) { $error = 1; $errstr[] = "The code you entered was incorrect"; } } if ($error == 1) { echo "<center>\n<font style=\"color: #FF0000\">\n"; foreach($errstr as $err) { echo "<li> " . $err . "</li>\n"; } echo "</font>\n</center>\n<br />\n\n"; showForm(); } else { @mail($to, "Site Contact - " . $_POST['bname'], "Add a Site,\n " . date("r") . ", " . $_POST['name'] . " " . $_POST['email'] . "\n\n Name:\n" . $_POST['name'] . "\n\n Phone:\n" . $_POST['phone'] . "\n\n Comments:\n" . $_POST['comments'] . "\n\n" . stripslashes($_POST['']), "From: " . $_POST['email']); $file_name = "test.csv"; $first_raw = "name,phone,email,comments\r\n"; $values = "name,phone,email,".str_replace ("\r\n","<BR>",comments )."\r\n"; $is_first_row = false; if(!file_exists($file_name)) { $is_first_row = true ; } if (!$handle = fopen($file_name, 'a+')) { die("Cannot open file ($file_name)"); exit; } if ($is_first_row) { if (fwrite($handle, $first_raw ) === FALSE) { die("Cannot write to file ($filename)"); exit; } } if (fwrite($handle, $values) === FALSE) { die("Cannot write to file ($filename)"); exit; } fclose($handle); echo "<center><font color=black>\nThank You. </font> <br /><br />" ."<font color=white>Click <a href=\"#\" onclick=\"self.close()\">here</a> to close this window.</font>"; } } //else submitted function showForm() { echo <<<EOD <form method="POST" class="cssform"> <br /> <br /> <hr/> <br /> <p><label for="name" class="required">*Name:</label> <input type="text" id="name" name="name" size="27" value="{$_POST['name']}"/></p> <p><label for="email" class="required">*Email:</label> <input type="text" id="email" name="email" size="27" value="{$_POST['email']}"/></p> <p><label for="phone" class="required">*Phone:</label> <input type="text" id="phone" name="phone" size="27" value="{$_POST['phone']}"/></p><br /> <p><label for="Comments">Comments:</label> <input type="text" id="comments" size="27" name="comments" /></p> <span class="table2"> *Type the characters: <input name="imagetext" type="text" size="5" /> <img src="securimage_show.php"> </span><br /> <br /> <hr/> <br /> <div style="margin-left: 25px;"> <input type="submit" class="formbutton" value="Submit" name="submit"/> <input type="reset" class="formbutton" value="Clear Form" /> </div> </form> EOD; } ?> Quote Link to comment Share on other sites More sharing options...
grk101 Posted March 16, 2008 Author Share Posted March 16, 2008 anyone can help? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.