Jump to content

argan328

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

argan328's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm going to try to use this basic session code I found at http://www.weberdev.com/get_example-4175.html <?php class sessions { /********************************************** ** ** Beginner's session handling class ** ** Author..: leapinglangoor [ leapinglangoor@yahoo.co.in ] ** Date....: 30th May 2005 ** Ver.....: v1.00 ** ** Desc....: This is a beginner's class to use sessions. ** This is meant more for for educational purposes rather ** than implimentation. There should be no problems using this. ** **********************************************/ /***************************** ** func - sessions() ** @Constructor ** @Access - public ** @Desc - The cunstructor used for warming up ** and preparing the sessions. ** @params - None *****************************/ function sessions() { // Let's initialise the sessions session_start(); } /***************************** ** func - set_var() ** @Access - public ** @Desc - Set a session variable ** @param $var_name - the variable name ** @paran $var_val - value for $$var_name *****************************/ function set_var( $var_name, $var_val ) { if( !$var_name || !$var_val ) { return false; } $_SESSION[$var_name] = $var_val; } /***************************** ** func - get_var() ** @Access - public ** @Desc - Get a session variable ** @param $var_name - the variable name to be retrieved *****************************/ function get_var( $var_name ) { return $_SESSION[$var_name]; } /***************************** ** func - delete_var() ** @Access - public ** @Desc - Delete a session variable ** @param $var_name - the variable name to be deleted *****************************/ function del_var( $var_name ) { unset( $_SESSION[$var_name] ); } /***************************** ** func - delete_vars() ** @Access - public ** @Desc - Delete session variables contained in an array ** @param $arr - Array of the elements ** to be deleted *****************************/ function del_vars( $arr ) { if( !is_array( $arr ) ) { return false; } foreach( $arr as $element ) { unset( $_SESSION[$element] ); } return true; } /***************************** ** func - delete_all_vars() ** @Access - public ** @Desc - Delete all session variables ** @params - None *****************************/ function del_all_vars() { del_all_vars(); } /***************************** ** func - end_session() ** @Access - public ** @Desc - Des! ! troy the session ** @params - None *****************************/ function end_session() { $_SESSION = array(); session_destroy(); } }// End class sessions ?> example.php: <?php include( 'class.session.php' ); // Use this in every page you wa! nt to use sessions first $sess = new sessions() // To set a variable $name = 'langoor, leapinglangoor'; $sess->set_var( 'name', $name ); // Let's retrieve it $name_got = $sess->get_var( 'name' ); // Let's delete the var $sess->del_var( 'name' ); // We're done let's exit $sess->end_session(); ?>
  2. Thx Caesar. I would expect this code go on every one of the content pages (I know HTML better than PHP at this point)-- but would I set the variable 'tos' in the session class itself or on the index page? Argan
  3. Hi I have created a website with a terms of service statement and a checkbox on the index page... users have to agree to the TOS before viewing the contents of the site. If a user has not agreed to the TOS and tries to link directly into one of the content pages I want them to be redirected to the index page until they click on the checkbox... I don't want to require a password, I just want them to click on the checkbox at each session. I think I need a session class but am not sure if that would do the job. Can anyone help confirm that a session class alone would accomplish this?? Thanks so much! Argan
  4. I added one to the email class and that did it! Thanks thorpe!
  5. sorry, that would have helped I don't see a Header property: <?php /* Class: Email * Desc: Stores an email message. */ class Email { private $message; private $addr; private $subj; function setMessage($message) { if(!is_string($message)) throw new Exception("Message must be a string"); else { $this->message = $message; return TRUE; } } function setAddr($addr) { if(!is_string($addr)) { throw new Exception("Address must be a string."); return FALSE; } else { $this->addr = $addr; return TRUE; } } function setSubj($subj) { if(!is_string($subj)) throw new Exception("Subject must be a string"); else { $this->subj = $subj; return TRUE; } } function sendEmail() { if(!empty($this->subj) and #49 !empty($this->addr) and !empty($this->message)) { if(!mail($this->addr,$this->subj,$this->message)) throw new Exception("Email could not be sent."); else return TRUE; } else #58 { throw new Exception("Subject, Address, and message are required. One or more is missing"); return FALSE; } } } ?>
  6. Hi, When the new user receives the registration email the "From" is the system generated xxxx@p3slxxx.shr.p..., but I want to set $headers = "From: do_not_reply@xxxxxx.com"; I have tried several ideas including the equivalent code from PHP manual <?php header('WWW-Authenticate: Negotiate'); header('WWW-Authenticate: NTLM', false); ?> with the 'false' after the second header but can't get it to work, can anyone help? $em = new Email(); #156 $em->setAddr($newdata['email']); $em->setSubj("Your xxxxxx.com member registration"); $emess = "Thank you for joining the xxxxxx.com community!"; $emess .= "Your new member account has been setup.\n\n"; $emess .= " Your new user name and password are: "; $emess .= "\n\n\t{$newdata['user_name']}\n\t"; $emess .= "{$newdata['password']}\n\n"; $emess .= "If you have any questions or problems,"; $emess .= " please visit our client help center at http://www.xxxxxx.com/yb_helpcenter"; $em->setMessage($emess); $em->sendEmail(); #167 } catch(Exception $e) { echo $e->getMessage(); exit(); } header("Location: ../members.html"); } } ?>
  7. Thanks Richard, I will not be able to test it until back home Friday but appreciate the code. It looks like the only difference is $sql="SELECT * FROM $tbl_name ORDER BY ward,street_1,street_nmbr"; looking forward to testing it. Argan
  8. that gave me an output that looks like this which pops up for a split second.... About to execute DELETE FROM test_mysql WHERE id='' About to execute DELETE FROM test_mysql WHERE id='' About to execute DELETE FROM test_mysql WHERE id='' About to execute DELETE FROM test_mysql WHERE id='' About to execute DELETE FROM test_mysql WHERE id='' About to execute DELETE FROM test_mysql WHERE id='' this variable exists Delete multiple rows in mysql # Id Name Lastname Email 1 Billly Blueton bb5@phpeasystep.com 2 Jame Campbell jame@somewhere.com 3 Mark Jackson mark@phpeasystep.com 4 Linda Travor lin65@phpeasystep.com 5 Joey Ford fordloi@somewhere.com 6 Sidney Gibson gibson@phpeasystep.com and then the top part disappears and I'm left with this: this variable exists Delete multiple rows in mysql # Id Name Lastname Email 1 Billly Blueton bb5@phpeasystep.com 2 Jame Campbell jame@somewhere.com 3 Mark Jackson mark@phpeasystep.com 4 Linda Travor lin65@phpeasystep.com 5 Joey Ford fordloi@somewhere.com 6 Sidney Gibson gibson@phpeasystep.com ...nothing is actually deleted
  9. I appreciate the idea, I tried this and I get nothing printed out? $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; echo "About to execute $sql<br>"; $result = mysql_query($sql) or die("Query failed: $sql\n" . mysql_error()); I also placed this at the end of the script after mysql_close(); if(isset($del_id)) { echo "this variable exists"; } else{ echo "this variable is empty"; } ?> for $del_id, $checkbox[$i], $i I get "this variable is empty"... also I noticed that $sql is defined twice, once near the top as $sql="SELECT * FROM $tbl_name"; and once toward the bottom as $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; is that a problem? I think the undefined variables are the problem but don't know what they should be defined as... can anyone help? Thanks Argan
  10. Hi, I pulled this code from http://www.phpeasystep.com/mysqlview.php?id=8 but can't get it to actually delete the rows I mark the checkbox... I think the problem is that $delete has no value, I'm just not sure what it should store? The weird thing is when I assign $delete a value like $delete="I like ice cream" it launches into a never ending loop! Can someone tell me what's wrong? ...thanks in advance! <?php $host="xxxxxxxxxxxx"; // Host name $username="xxx"; // Mysql username $password="xxxxx"; // Mysql password $db_name="xxxxxxx"; // Database name $tbl_name="test_mysql"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Delete multiple rows in mysql</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php // Check if delete button active, start this ----- this is where i think the problem is with $delete if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysql_close(); ?> </table> </form> </td> </tr> </table>
  11. the truth is I've been playing with it for a few hours now and shortly after I posted this question it stopped giving me the error. I still have the same $body="Hey, go take a look at the site because someone's left a guestbook entry!"; which is really weird but I did change a bunch of other stuff so I'm wondering if the problem wasn't really with that line of code. although I'd like to know what was wrong the good news is it's solved (somehow!) Thanks! Argan
  12. Can someone tell me why I'm getting the following error? Warning: mail() expects parameter 3 to be string, array given in /home/content/x/x/x/xxxxxxx/html/guestbook/sign.php on line 314 here is the code: $to="jilly@xxxxxx.com"; $subject="Someone has signed the guestbook!!"; $body="Hey, go take a look at the site because someone's left a guestbook entry!"; $headers="From: guestbook_notify@xxxxxxxx.com"; mail($to, $subject, $body, $headers); //this is line 314
  13. yea search internet, I there is a TON of information online. I've often found myself here http://www.sitepoint.com/recentarticles/ which is not all PHP but there is a lot of great stuff, also just google whatever you want to know and you'll find tutorials galore. Good luck!
  14. can anyone tell me why neither of my echos would be showing up?
  15. now I'm getting no response, neither of my echo's are showing up... I think my $stringout in the if statement may be messing things up. if you recall from above I thought I was going to have to implode the array so I created $stringout and plopped it in the if statement. I know the problem is somewhere in the code below... do you know why I would not get either of my echo statements? sorry to be such a pain on this one but I'm coming up on my deadline! :-\ //implode the string $stringout = implode(",", $param); echo $stringout; // Submit message to the database if (isset($_POST['$stringout'])) { $stringout = $_POST['$stringout']; $sql = "INSERT INTO messages SET calleridname='{$param['calleridname']}', create_date=CURDATE(), callerid='{$param['calleridid']}', phonenumber='{$param['phonenumber']}', message='{$param['message']}' "; if (@mysql_query($sql)) { echo '<p>Your array has been added.</p>'; //neither of these are showing up now?? } else { echo '<p>Error adding submitted message: ' . mysql_error() . '</p>'; } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.