Re: help on modifications / subscribe / unsubscribe script

From: Date: Sat, 10 Mar 2001 18:18:14 +0000
Subject: Re: help on modifications / subscribe / unsubscribe script
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7278@lists.php.net to get a copy of this message
-----Mensagem Original----- De: Marc Bragg <msbjustice@mindspring.com> Para: <php-db@lists.php.net> Enviada em: sábado, 10 de março de 2001 14:46 Assunto: [PHP-DB] help on modifications / subscribe / unsubscribe script > Am using the following subscribe/unsubscribe script with great success, > but it does not have all the functionality I would like. Any one have > any ideas on how to: > > 1. open in a java window, and once info is put, and person is > subscribed, java window closes and a selected http page comes up? If the selected http page can be opened in a new window you can do as follow: open window : nWnd = window.open("URL","handle_var","window_configuration"); // Omitted parameters are treated in default mode. show passoword as "*" : <input type="password" name="pwd"> Form configuration: <form action="your_script.php" target="_blank" method="post"> Do not use submit button, use a standard button istead (<input type="button" OnClick="subAction(this.form);">), write a submit function to use associated with button OnClick event : function subAction(aForm){ // process aForm.submit(); // Close the subscribe window self.close(); } > > 2. compare information submitted in this table, with same variable in > another table, and if data is not there, then include it? $query = "select from table where field = $value" ; // Submit the query , it depends on the database you are using if( "there is a row at least"){ // Found - condition is database dependant file://process } else{ // process $query = "insert into table values (,,,,,)"; } // If you are using MySQL you can search for the "replace" command on the manual Wait for time stamp advice, I didn't work much with it. HTH Jayme. > > 3. make the password show up as ***** characters in the browser rather > than the lettters typed by user, and add a portion of script to compare > to what is in database, and if there, is it correct. > > 4. how to add minute and seconds to date stamp. > > Thanx > > Marc > > > <?php > // connect to db > $db = mysql_connect("xxxxx","yyy") or die ("Couldn't > connect."); > > mysql_select_db("law", $db) or die ("Couldn't select db."); > > // get a date stamp > $add_date = date("Y-m-d"); > > if ($op != "ds") { > file://they need to subscribe or unsubscribe > $text_block = " > <form name=\"form\" method=post action =\"subscribe.phtml\"> > <input type=hidden name=op value =ds> > > <p><strong>Enter Your e-Mail Address. This will be your User > Name:</strong><br> > <input type=text name=\"email\" size=25></p> > <p><strong>Enter a Password.</strong><br> > <input type=text name=\"password\" size=25></p> > > > <p><strong>Click your selection:</strong><br> > <input type=radio name=\"action\" value=\"sub\" checked> Subscribe > <input type=radio name=\"action\" value=\"unsub\"> > Unsubscribe</p> > > <p><input type=submit name=\"submit\" value=\"Subscribe / Unsubscribe > Now\"></p> > </form> > > "; > > } > > else if (($op == "ds") && ($action == "sub")) { > > // check they're not already subscribed > // then subscribe them or return message > > $check = "select email from subscribe > where email = \"$email\""; > > $check_result = mysql_query($check) > or die("Can't execute check email address."); > > $check_num = mysql_num_rows($check_result); > > if ($check_num == 0) { > > // if $check_num is 0, then no match was found, > // and the user should be subscribed > > $sql = "insert into subscribe (email, password, add_date, > sub_id) values(\"$email\", \"$password\", \"$ > add_date\", \"\")"; > > @mysql_query($sql) or die ("Couldn't insert email."); > > $text_block = " > <p><h1><center><font color=green>Thanks for Joining Bid > Attorney!</h1></center></font></p> > "; > > } else { > > // if $check_num is not 0, then the user is > // already subscribed, and let them know it. > > $text_block = " > <p><font color=green><b>You are already a member of Bid > Attorney. Thank you!</b></font></p> > "; > > } > } > > else if (($op == "ds") && ($action == "unsub")) { > > // check they're already subscribed, > // then unsubscribe them or return message. > > $check = "select email from subscribe > where email = \"$email\""; > > $check_result = mysql_query($check) > or die("Can't execute check e-mail address."); > > $check_num = mysql_num_rows($check_result); > > if ($check_num == 0) { > > // if $check_num is 0, then no match is found, > // and the user cannot be unsubscribed > > $text_block = " > <p><font color=red><b>Couldn't find your e-mail / user name on > the list.</b></font></p> > <p><i>You haven't been unsubscribed because the e-Mail you > entered is not in > the database.</i>"; > > } else { > > // if $check_num is not 0, then the user is on the list, so can > be unsubscribed. > > $sql = "delete from subscribe > where email = \"$email\""; > > @mysql_query($sql) or die ("Couldn't delete email."); > > $text_block = " > <p><font color=black><b> You are unsubscribed from the Bid > Attorney Database!<i> Hope to see you back s > oon!</i></b></font></p> > "; > } > } > > ?> > > <html> > <head> > <title>Form: Join the Bid Attorney Database / username - > password</title> > </head> > <body> > > <h1><font color=blue><center>Use this Form to Subscribe / > Unsubscribe<br> to the <br>Bid Attorney Database.</ce > nter></font></h1> > > <?php echo "$text_block"; ?> > > </body> > </html> > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#7278) next »