
NETSYNC
Members-
Posts
22 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
NETSYNC's Achievements

Newbie (1/5)
0
Reputation
-
I am going to try this tonight. Thanks very much for the reply and the tip! Hopefully this is it!
-
Hey guys. I am using Usercake to build a small user login site with only 2 pages. My problem is that for some reason when I log in the first time it works. But after I submit a form which enters info into a database, upon return the session is dead. Nowhere in these files should be killing the session. Then when I login the second time and do all the same stuff it works flawlessly until I logout. My question is: How to troubleshoot sessions? How can I pinpoint where exactly the session is getting killed? I am at a loss on how to figure out where the issue is. Thanks for any tips!
-
I figured it out actually. I simply made the second section and ELSE of the top if instead of two seperate. So if the field is empty it does not even check the database at all.
-
Hey all. I have a simple code for verifying some data. I have two echos from if statements. The first is if the text input is empty echo: HELLO. The second is if text input data is not found in database echo: NOPE. Now in the following code the second one works fine. But the problem is if I leave the field empty BOTH echos show. So if I leave the input empty instead of saying "HELLO" it says, "HELLONOPE". Yet the second one works fine and display only "NOPE" The other thing is if I switch the two echos to die instead, they work fine. if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['id']) { echo "HELLO"; } // checks it against the database $check = mysql_query("SELECT * FROM emp WHERE id = '".$_POST['id']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { echo "NOPE"; } else { //if login good then redirect them to the members area $id = $_POST['id']; header("Location: somepage.php?id=$id"); } } else { // they are not logged in } <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <input type="text" name="id" maxlength="40"> <input type="submit" name="submit" value="Login"> </form> What am I doing wrong?
-
Oh duh me! It works now! Thank you sir!
-
Ok based on that I did this. Now neither validate and the script errors on submit. The error is: "Fatal error: Call to undefined function validateForm() in /nfs/c06/h02/mnt/94387/xxxxxxx/formtest.php on line 12" <?php // options for drop-down menu $choices = array('-- Choose Your Item','Anniversary Jacket', 'Anniversary T-Shirt'); $sizes = array('-- Choose Your Size','L', 'XL'); if($_SERVER['REQUEST_METHOD'] == 'GET'){ // display form when GET showForm(array()); } else{ // process form if POST $errors = validateForm(); if(count($errors)) showForm($errors); // if errors show again else print 'Form submitted succesfully!'; // no errors } // function generating form function showForm($errors){ global $choices,$sizes; // set defaults $defaults = array(); foreach($choices as $key => $choice){ if(isset($_POST['item']) && ($_POST['item'] == $key)) $defaults['item'][$key] = 'selected'; else $defaults['item'][$choice] = ''; } foreach($sizes as $key => $size){ if(isset($_POST['size']) && ($_POST['size'] == $key)) $defaults['size'][$key] = 'selected'; else $defaults['size'][$size] = ''; } // print form print "<form action='{$_SERVER['SCRIPT_NAME']}' method='post'>"; print "<div>"; print "<select name='item'>"; foreach($choices as $key => $choice){ print "<option value='{$key}' {$defaults['item'][$key]}>{$choice}</option>"; } print "</select>"; showError('item', $errors); print "</div>"; print "<div>"; print "<select name='size'>"; foreach($sizes as $key => $size){ print "<option value='{$key}' {$defaults['size'][$key]}>{$size}</option>"; } print "</select>"; showError('size', $errors); print "</div>"; print "<input type='submit'/>"; print "</form>"; } // display error function showError($type, $errors){ if(isset($errors[$type])) print "<b>{$errors[$type]}</b>"; } // $errors = array();//empty array function Validate() { if(!(isset($_POST['size']) && (array_key_exists($_POST['size'], $choices)) && $_POST['size'] != 0)) { $errors[size] = "Selet Size"; } if(!(isset($_POST['item']) && (array_key_exists($_POST['item'], $choices)) && $_POST['item'] != 0)) { $errors[item] = "Select Item"; } return $errors; } // ?> Thanks for the help! Learning as I go here.
-
Thanks for the reply. Makes perfect sense. How would I make an errors array and then return it at the end? I know how to make arrays with just data, but how do I do that based on a condition?
-
I am working on a script for a simple form with only 2 options that are dropdowns. I need to validate these two options that there is a selection made. I have gotten the first one to validate, but I cannot get the second one to validate. Can anyone steer me in the right direciton why only one is working? I get no errors in the script, so I assume I am just missing something. <?php // options for drop-down menu $choices = array('-- Choose Your Item','Anniversary Jacket', 'Anniversary T-Shirt'); $sizes = array('-- Choose Your Size','L', 'XL'); if($_SERVER['REQUEST_METHOD'] == 'GET'){ // display form when GET showForm(array()); } else{ // process form if POST $errors = validateForm(); if(count($errors)) showForm($errors); // if errors show again else print 'Form submitted succesfully!'; // no errors } // function generating form function showForm($errors){ global $choices,$sizes; // set defaults $defaults = array(); foreach($choices as $key => $choice){ if(isset($_POST['item']) && ($_POST['item'] == $key)) $defaults['item'][$key] = 'selected'; else $defaults['item'][$choice] = ''; } foreach($sizes as $key => $size){ if(isset($_POST['size']) && ($_POST['size'] == $key)) $defaults['size'][$key] = 'selected'; else $defaults['size'][$size] = ''; } // print form print "<form action='{$_SERVER['SCRIPT_NAME']}' method='post'>"; print "<div>"; print "<select name='item'>"; foreach($choices as $key => $choice){ print "<option value='{$key}' {$defaults['item'][$key]}>{$choice}</option>"; } print "</select>"; showError('item', $errors); print "</div>"; print "<div>"; print "<select name='size'>"; foreach($sizes as $key => $size){ print "<option value='{$key}' {$defaults['size'][$key]}>{$size}</option>"; } print "</select>"; showError('size', $errors); print "</div>"; print "<input type='submit'/>"; print "</form>"; } // display error function showError($type, $errors){ if(isset($errors[$type])) print "<b>{$errors[$type]}</b>"; } // validate data function validateForm(){ global $choices,$sizes; // start validation and store errors $error = array(); // validate drop-down if(!(isset($_POST['item']) && (array_key_exists($_POST['item'], $choices)) && $_POST['item'] != 0)) $errors['item'] = 'Select Item'; return $errors; // validate drop-down if(!(isset($_POST['size']) && (array_key_exists($_POST['size'], $choices)) && $_POST['size'] != 0)) $errors['size'] = 'Select Size'; return $errors; } ?>
-
Changing an email script to do batches instead?
NETSYNC replied to NETSYNC's topic in PHP Coding Help
Any help on why this would cause an implode error? Did I separate them wrong? -
Changing an email script to do batches instead?
NETSYNC replied to NETSYNC's topic in PHP Coding Help
Here is what I am trying but it is giving me an implode error. <?php if(!empty($_POST["recip"])){ switch ($_POST["recip"]) { case 'sl': $q = "select `num` from `sprint` WHERE dept ='T_SUP' OR `dept` ='T_LEAD' OR `dept` ='M_LEAD' OR `dept` ='T_MGR' OR `dept` ='T_VP' OR `dept` ='M_MGR'"; break; case 'mgt': $q = "select `num` from `sprint` WHERE dept ='T_SUP' OR `dept` ='S_SUP' OR `dept` ='O_MG' OR `dept` ='T_MGR' OR `dept` ='S_VP' OR `dept` ='Q_SUP' OR `dept` ='S_MGR' OR `dept` ='T_VP' OR `dept` ='M_MGR'"; break; case 'sunday': $q = "select `num` from `sprint` WHERE id ='7708' OR `id` ='7743' OR `id` ='7426' OR `id` ='7479' OR `id` ='7203' OR `id` ='7231' OR `id` ='7271' OR `id` ='7221'"; break; case 'sil': $q = "select `num` from sprint WHERE `sup` ='Silvio'"; } if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); } $ret = mysql_query($q); $emails = array(); while ($row = mysql_fetch_assoc($ret)) { $emails[] = $row['num'].'@messaging.sprintpcs.com'; } array_chunk($emails, 50); if ($emails) { foreach($emails as $mail) { $ToEmail = implode(', ', $mail); $EmailSubject = $_POST["subject"]."\r\n"; $mailheader = "From: ".$_POST["email"]."\r\n"; $MESSAGE_BODY = ($_POST["message"]); // $MESSAGE_BODY .= ($_POST["auth"]); mail($ToEmail,$EmailSubject, $MESSAGE_BODY,$mailheader) or die ("Failure"); } } $num_rows = mysql_num_rows($ret); ?> -
Hey all I have this code: $ret = mysql_query($q); $emails = array(); while ($row = mysql_fetch_assoc($ret)) { $emails[] = $row['num'].'@messaging.sprintpcs.com'; } if ($emails) { $ToEmail = implode(', ', $emails); $EmailSubject = $_POST["subject"]."\r\n"; $mailheader = "From: ".$_POST["email"]."\r\n"; $MESSAGE_BODY = ($_POST["message"]); // $MESSAGE_BODY .= ($_POST["auth"]); mail($ToEmail,$EmailSubject, $MESSAGE_BODY,$mailheader) or die ("Failure"); } This has worked great for a custom script that emails users the content of a form. The issue is with the number of emails. It can get up to 200 or so and when it does the emails never come. We are assuming its hitting something on the server end or after it leaves. My next idea is to break this script up so it does it in batches instead of how it is now. Where would I start on this to do the exact same thing, but do it in batches of 50 if its more than that? Thanks for any insight and help.