ciao ragazzi avrei bisogno un vostro aiuto, in uno script per l iscrizione alla newsletter vorrei mettere due pulsanti radio uno che sia inscrivimi e uno cancellami come potrei fare?
ho provato in tanti modi ma non mi riesce mi date una mano grazie
Io uso qusti script per l inserimento dei dati e il controlo delle email
Codice PHP:
include_once("config.php");
//No need to change anything below ...
// Gets the date and time from your server
$date = date("d/m/Y H:i:s");
// Gets the IP Address
if ($_SERVER['REMOTE_ADDR'] == "")
{
$ip = "no ip";
}
else
{
$ip = gethostbyaddr($_SERVER['REMOTE_ADDR']);
}
// Gets the POST Headers - the Flash variables
$action = $_REQUEST['action'] ;
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$decide =$_REQUEST['decide']?1:0;
//Process the form data!
// and send the information collected in the Flash form to Your nominated email address
if ($action == "send")
{
//Innanzitutto controlliamo la var.le name:
$controllo = check_username($name,$email);
if ($controllo != "OK")
{
echo $controllo;
//Qui potresti anche far visualizzare una cosa del genere:
echo "
<A HREF=\"http://www.marikweb.com/homeita/\">Ritorna alla registrazione</A>";
}
else
{
//Ora inseriamo i dati nel DB.
//Ovviamente devi creare una tabella in cui inserire i dati ke passi con il post.
$link_db = mysql_connect($CONFIG['host'],$CONFIG['user'],$CONFIG['pass']);
mysql_select_db($CONFIG['dbname']);
$sql_insert = "INSERT INTO mailing (name,email) VALUES ('$name','$email')";
if (mysql_query($sql_insert))
{
echo "OK RIGA INSERITA
";
}
else
{
die(mysql_error());
}
mysql_close($link_db);
/*
//A questo punto inviamo l'e-mail
mail ("$adminaddress","informazioni",
"L'utente: $name si è iscritto alla MailingList \n
------------------------------
Name Utente: $name
EmailUtente: $email\n
------------------------------
Logged Info :
------------------------------
Using: {$_SERVER['HTTP_USER_AGENT']}
Hostname: $ip
IP address: {$_SERVER['REMOTE_ADDR']}
Date/Time: $date","FROM:$email" ) ;
*/
}
}//
<FORM METHOD=POST ACTION="mess.php" name="test">
name<INPUT TYPE="text" NAME="name">
email<INPUT TYPE="text" NAME="email">
<select name="decide">
<option value="1" selected>inserisci</option>
<option value="0">cancella</option>
</select>
<INPUT TYPE="hidden" name="action" value="send">
<INPUT TYPE="submit">
</FORM>
e questo e per il controllo dei campi
Codice PHP:
$CONFIG['host'] = "localhost";
$CONFIG['user'] = "root";
$CONFIG['pass'] = "maurizio";
$CONFIG['dbname'] = "joo";
$CONFIG['expire'] = 60;
$CONFIG['regexpire'] = 24; //in ore
$CONFIG['check_table'] = array(
"name" => "check_global",
"email" => "check_global"
);
function check_username($value,$value1)
{
global $CONFIG;
$value = trim($value);
$value1 = trim($value1);
if (($value == "")||($value1 == ""))
{
echo"Il campo non può essere lasciato vuoto";
}
else{
$query = @mysql_query("SELECT id FROM mailing WHERE email='$value1'") or die("Errore nella query");
if (@mysql_num_rows($query) != 0){ return" $value1 già utilizzato ";}else{return"OK";}
}
}
//--------------
define('AUTH_LOGGED', 99);
define('AUTH_NOT_LOGGED', 100);
define('AUTH_USE_COOKIE', 101);
define('AUTH_USE_LINK', 103);
define('AUTH_INVALID_PARAMS', 104);
define('AUTH_LOGEDD_IN', 105);
define('AUTH_FAILED', 106);
define('REG_ERRORS', 107);
define('REG_SUCCESS', 108);
define('REG_FAILED', 109);
$conn = @mysql_connect($CONFIG['host'], $CONFIG['user'], $CONFIG['pass']) or die('Impossibile stabilire una connessione');
@mysql_select_db($CONFIG['dbname']) or die("Errore nel DB");