Web form scripts

    get_addresses.php

    <? /** * Variables */ $addlist = 'addlist.csv'; // Filename with subscribers: please change for security purpose $removelist = 'deletelist.csv'; // Filename with unsubscribers: please change for security purpose $pass = 'qwerty'; // Access password: change for security purpose $form_type = '2'; // Type of form: 1 - only email, 2 - email and name /** * */ $key_url = $_SERVER['REQUEST_URI']; if (strpos($key_url,"?") !== false) { $get_add = "&"; $key_url = explode('key_status=',$key_url); $key_url = $key_url[0]; } else { $get_add = "?"; } if (@isset($_GET['pass']) && $_GET['pass'] != '' && @$_GET['pass'] == md5($pass)){ if (@isset($_GET['add'])){ read_output_clear_file ($addlist); } else if (@isset($_GET['remove'])){ read_output_clear_file ($removelist); } else echo 'ERROPER'; } else if (isset($_GET['pass']) && $_GET['pass'] != '') echo 'ERRPASS'; function read_output_clear_file ($filename){ $f = fopen($filename, "r"); print(fread($f, filesize($filename))); fclose($f); $f = fopen($filename, "w+"); fclose($f); } function check_record_exist ($filename, $email, $type = 1){ if (file_exists($filename)){ $keys = file($filename); $kcnt = count($keys); $exist = 0; for ($i = 0; $i < $kcnt; $i++){ if ($type == 1){ if ($keys[$i] == "$email\n") { $exist = 1; break; } } else { $data = split(";", $keys[$i]); if ($data[0] == "$email") { $exist = 1; break; } } } if ($exist == 0) return $exist; else return ($i+1); } else return 0; } function add_record ($filename, $email, $name = ''){ $f = fopen($filename, "a+"); if ($name == '') fwrite($f, "$email\n"); else fwrite($f, "$email;$name\n"); fclose($f); } function delete_line_from_file ($filename, $line){ if (file_exists($filename)){ $data=file($filename); $f=fopen($filename,'w'); $size=count($data); for ($i = 0; $i < $size; $i++) if ($i != $line) fputs($f,$data[$i]); fclose($f); } } ?>

    form.php

    <? include_once("get_addresses.php"); @$email = strtolower(trim($_POST['email'])); @$name = trim($_POST['name']); @$type = $_POST['type']; if (isset($_POST) && count($_POST) != 0){ if (@isset($email) && @$email != ''){ if (@isset($type)){ switch ($type){ case '1': { $line = check_record_exist ($removelist, $email, $form_type); if ($line){ $line--; delete_line_from_file ($removelist, $line); } if (!check_record_exist ($addlist, $email, $form_type)){ add_record ($addlist, $email, $name); header('Location: '.$key_url.$get_add.'result=1'); exit(); } else { header('Location: '.$key_url.$get_add.'result=3'); exit(); } } case '0': { $line = check_record_exist ($addlist, $email, $form_type); if ($line){ $line--; delete_line_from_file ($addlist, $line); } if (!check_record_exist ($removelist, $email, $form_type)){ add_record ($removelist, $email, $name); header('Location: '.$key_url.$get_add.'result=2'); exit(); } else { header('Location: '.$key_url.$get_add.'result=4'); exit(); } } } } else echo '<font color="#FF0000">Please specify type of action</font>'; } else echo '<font color="#FF0000">Please enter e-mail address</font>'; } if (isset($_GET['result'])) { switch ($_GET['result']){ case '1': echo '<b>You have successfully subscribed</b>'; break; case '2': echo '<b>You have successfully unsubscribed</b>'; break; case '3': echo '<b>You are already subscribed</b>'; break; case '4': echo '<b>You are already unsubscribed</b>'; break; } } else { ?> <form method="POST"> <table cellpadding="0" cellspacing="1" bgcolor="#aaaaaa"><tr><td> <table cellpadding="5" cellspacing="0" bgcolor="white" width="100%" height="100%"> <tr bgcolor="white"> <td><label for="atomic__e">E-mail:</label></td> <td><input type="text" maxlength="200" id=atomic__e size="40" name="email" value="<?=@$_REQUEST['email'];?>" /></td> </tr> <? if ($form_type != 1) { ?> <tr bgcolor="white"> <td><label for="atomic__n">Name:</label></td> <td><input type="text" id="atomic__n" maxlength="200" size="40" name="name" value="<?=@$_REQUEST['name'];?>" /></td> </tr> <? } ?> <? if (!isset($_REQUEST['type'])){?> <tr bgcolor="white"> <td> </td> <td><input type="radio" id="atomic__s" name="type" value="1" checked /> <label for="atomic__s">Subscribe</label><br> <input type="radio" id="atomic__u" name="type" value="0" /> <label for="atomic__u">Unsubscribe</label></td> </tr> <? } else { ?> <input type="hidden" name="type" value="<?=@$_REQUEST['type'];?>" /> <? } ?> <tr bgcolor="white"> <td></td> <td><input type="submit" name="submit" value="<? if (@isset($_REQUEST['type']) && $_REQUEST['type'] == 1) echo "Subscribe"; else if (@isset($_REQUEST['type']) && $_REQUEST['type'] == 0) echo "Unsubscribe"; else echo "Submit";?>"></td> </tr> <tr bgcolor="#aaaaaa"> <td align="center" colspan="2"><a href="https://www.massmailsoftware.com/manager/" target="_blank"> <font face="Verdana" size="-2">Powered by ASM</font></a></td> </tr></table></table> </form> <? } ?>
    We use cookies to provide you with the best experience while using our site Yes, I agree