Jump to content

davids701124

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

davids701124's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. even i corrected the variable, it still print empty. also for security problem, do u have any suggestion or wht should be the correct and good way to do.
  2. I can get the email, but there is empty for $password. is there anything i did wrong? <?php require('dbconnect.php'); $email = $_POST['email']; $email = mysql_real_escape_string($email); $table = "user"; $sql = "SELECT user_email FROM $table WHERE user_email = '$email'"; $result = mysql_query($sql); //mysql_num_rows is counting table now $count = mysql_num_rows($result); //if the email is correct will be counted 1 if($count == 1){ //send password to the user through email while( $rows = mysql_fetch_array($result) ){ $password = $row['user_pass']; } //send mail form //subject $subject="Your Password!!"; // From $header="from: BabyTracker <your email>"; // Your message $messages = "There is your password for login.\n Password is ".$password; // send email $sentmail = mail($email,$subject,$messages,$header); //if password form was sent successfully if($sentmail){ echo "Your password has been sent to your email."; } else { echo "Sorry! We can't send password to you email box."."<BR>"; echo "Contact us by phone."; } } else { echo "Have you signed up? The system can't find your email?"."<BR>"; } ?>
  3. $baby_id is used to replace $_SESSION[baby_id], it is a id number auto-increasing after user registered.
  4. I made a form with session method to store particular's id when user is submit new event. however, according to my code, everything was store into the table correctly, except $_session[baby_id], can anyone help out?? <?php //set up session! session_start(); //connect to db require( "dbconnect.php" ); //check seesion is set or not if(isset($_SESSION['username'])){ echo "Welcome, ".$_SESSION['username'].". "; echo "Your baby_id is ". $_SESSION['baby_id'].".<BR>"; } else { echo "please login!"; } $_SESSION['baby_id'] = $baby_id; //insert entry $sql="INSERT INTO post (post_title, post_des, photo1_url, photo2_url, photo3_url, baby_id) VALUES ('$_POST[title]','$_POST[des]','$_POST[p1]','$_POST[p2]','$_POST[p3]','$baby_id')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "the entry is added"; ?>
  5. after using array_merage(), i think the result is a little bit different from what I tend to do. I think what I need is multidimensional arrays, say $posts and $events are array and containing some information already, and I wanna they are contained in a new array.So how to use it?
  6. I wanna push 2 arrays, event array and journal array, into the other array, so I can get the all result once. do I need to make the 2 array be variables first?? or just push them into the array directly anyway? this is what I have now: //check out baby's due date $weeks_expected = 42; $baby_id = $_SESSION['baby_id']; $days_expected = $weeks_expected * 7; $sql = "SELECT SUBDATE(due_date, INTERVAL $days_expected DAY) AS begin_date FROM baby WHERE baby_id = {$baby_id}"; $begin_date_query = mysql_query( $sql ); while ( $row = mysql_fetch_array($begin_date_query)){ print "Your baby's due date from baby table: ". $row["begin_date"] . "<br>"; $begin_date = $row['begin_date']; } //check out the posts for this baby id. $sql = "SELECT (DATEDIFF(post_date, '$begin_date') + 1) AS num_day, DATE(post_date) AS post_date, post_title, post_des FROM post WHERE baby_id = {$baby_id}"; print "!!!!! $sql !!!!!"; $posts_query = mysql_query( $sql ); while ( $row = mysql_fetch_assoc($posts_query)) { $num_day = $row['num_day']; $post_date = $row['post_date']; $post_title = $row['post_title']; $post_des = $row['post_des']; $posts[$num_day]['post_date'] = $post_date; $posts[$num_day]['post_title'] = $post_title; $posts[$num_day]['post_des'] = $post_des; } //check out the events for this baby id. $sql = "SELECT (DATEDIFF(start_datetime, '$begin_date') + 1) AS num_day, DATE(start_datetime) AS start_datetime, event_title, event_des FROM event WHERE baby_id = {$baby_id}"; $events_query = mysql_query( $sql ); while ( $row = mysql_fetch_assoc($events_query)) { $num_day = $row['num_day']; $event_date = $row['start_datetime']; $event_title = $row['event_title']; $event_des = $row['event_des']; $events[$num_day]['start_datetime'] = $start_datetime; $events[$num_day]['event_title'] = $event_title; $events[$num_day]['event_des'] = $event_des; } print "<PRE>"; print_r($posts); print "<BR>"; print_r($events); print "<BR>"; print "</PRE>";
  7. so u mean i should make it like {$_SESSION['baby_id']} ?
  8. there is a php i set: $begin_date_query = mysql_query( "SELECT SUBDATE(due_date, INTERVAL $days_expected DAY) AS begin_date FROM baby WHERE baby_id = $_SESSION['baby_id']" ); 'coz of the double quote, the variable $_SESSION['baby_id'] always be convert into string. how can i keep it as a variable, especially there is single quote go around!!! tried many combination but doesn't work. totally confused @@.
  9. not really, my first try didn't take anything away. I'm wondering why the table tag doesn't work either. Anyway, thanks for helping. I'm gonna try it more.
  10. After tried it, it prints out all date together without table. However, I think it is closed, I'm gonna try to tweak it for fitting what I exactly need. I'm wondering wht is the meaning of $DayCnt? Thank you very much.
  11. I have generate days between 2 dates, the code is following: $day = 24 * 60 * 60; $sTime = strtotime('2009-10-20'); //it doesn't work putting $row["user_registered"] $eTime = strtotime('2010-08-10'); //it doesn't work putting $row["user_registered"] $numDays = (($eTime - $sTime) / $day + 1); $numWeeks = $numDays / 7; print $numWeeks; and now I wanna create a table; the row is week number, ex: week1, week2,...;the column is day, from Mon to Sun. and each field will contain exactly date, ex: 2009-10-20.... So I'm wondering how can I know which day is belong which week?
  12. this is what I did until now, but after subtract the value is 0...weird?? $duedate = mysql_query( "SELECT due_date FROM baby WHERE baby_id = '29'" ); while ( $row = mysql_fetch_assoc($duedate)){ echo strtotime($row["due_date"])."<br>"; } $regi_date = mysql_query("SELECT user_registered FROM user WHERE user_id ='43'"); while ( $row = mysql_fetch_assoc($regi_date)){ echo strtotime($row["user_registered"])."<br>"; } $a = strtotime($row["due_date"]); $b = strtotime($row["user_registered"]); echo $a - $b."<br>";
  13. does this issue exist, even I was using date rather than datetime or timestamp??
  14. I have 2 dates, says 2010-11-24 and 2009-10-12 I wanna get the each date which between this duration belong to which week which day. So I think I have to sub them and divide 7, but no idea which function can convert them right. i check php reference, but not sure how to do it right? hope someone help, thank u.
×
×
  • 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.