PHP - Sign Up Page - Birth Date???
$username = $_POST['username']; $password = $_POST['password']; $month = $_POST['month']; $day = $_POST['day']; $year = $_POST['year']; $query = mysql_query("INSERT INTO users VALUES ('','$username','$password','$month','$day','$year') mysql_query($query); The code above is a sample of what I have but what I want is to store an entire birthdate in ONE SQL cell. More like this... $username = $_POST['username']; $password = $_POST['password']; $month = $_POST['month']; $day = $_POST['day']; $year = $_POST['year']; $query = mysql_query("INSERT INTO users VALUES ('','$username','$password','$birthdate') mysql_query($query); How is this possible? Can I do this and actually use it efficiently in the future? Similar TutorialsIs there a way to add a date of birth into a mysql but display it as the age?... e.g Mysql = 04/06/89 Display = 21 Hi guys, My apologies if this is in the wrong forum but I am not really sure how to go about this. I have not written any code for this but I have four fields in one table one called age and 3 others dobmonth / dobday /dobyear - My question being how would I write some code that automatically fills in the age field based on the date of birth fields? If anyone could point me in the right direction that would be awesome, Appreciated. Hi all, I'm having a bit of trouble a script running on a site where it converts a date of birth in a database shown like this '30/04/1993' to an actual age, for instance 18 in this case. Only the script I'm using below shows this age as 17, not 18 as it should be. Code: [Select] <?php $birthday = $row_getdets['dob']; function birthday ($birthday){ list($day,$month,$year) = explode("/",$birthday); $day_diff = date("d") - $day; $month_diff = date("m") - $month; $year_diff = date("Y") - $year; if ($day_diff < 0 || $month_diff < 0) $year_diff--; return $year_diff; } ?> So i've tried to remedy this myself with the following: Code: [Select] <?php $birthday = $row_getdets['dob']; function birthday ($birthday){ list($year,$month,$day) = explode("/",$birthday); $year_diff = date("Y") - $year; $month_diff = date("m") - $month; $day_diff = date("d") - $day; if ($month_diff < 0) $year_diff--; else if (($month_diff==0) && ($day_diff < 0)) $year_diff--; return $year_diff; } ?> ..but I'm having a syntax error (unexpected T_LINE), most probably down to my novice ability, I bet I've missed something simple. I'm still learning guys and I'd really appreciate any help at all. i have date of birth stored as DATE type in mysql. i tried this so it would show the age but it comes up blank. Code: [Select] $getprof = mysql_query("SELECT * FROM Profile WHERE username='$search'")or die(mysql_error()); while($rowprof = mysql_fetch_assoc($getprof)) { $username1 = $rowprof['username']; $location = $rowprof['location']; $gender = $rowprof['gender']; $dateofbirth = $rowprof['dateofbirth']; $information = $rowprof['information']; } function GetAge($dateofbirth) { // Explode the date into meaningful variables list($BirthYear,$BirthMonth,$BirthDay) = explode("-", $dateofbirth); // Find the differences $YearDiff = date("Y") - $BirthYear; $MonthDiff = date("m") - $BirthMonth; $DayDiff = date("d") - $BirthDay; // If the birthday has not occured this year if ($DayDiff < 0 || $MonthDiff < 0) $YearDiff--; return $YearDiff; } echo $YearDiff; Hi there, I'm new to PHP so sorry if this is a really basic question. How do i post date of birth collected from a form, into a database? I have the fields in the form set up as 'day' 'month' 'year' all of which are drop-down boxes. I tried doing it one way which i saw on a different website, but it didn't work. Here is what i tried: Code: [Select] '$_POST[day] . - . $_POST[month]' . - . $_POST[year]', More info: In the database table this information is going to, the "date of birth" field is set to "DATE" type. Don't know if that makes any difference I need to add date of birth field to registration form and then save it to databse. I cannot figure out what might be best way of storing the date in the table. I could convert it to unix epoch time, or I could do YYYYMMDD.
Thoughts? What would be the easiest method of saving the DOB?
I am not asking on how to do it, just the format. Thanks
Can you please help how to validate the date of birth in code igniter including leap years
hello fellas, need some help please if possible. i have created a date of birth section in my form where the user selects his/her date of birth from the dropdown menu. they would first select the day then month then year of their birthday. how would i setup the database to get this to work? i currently have: Code: [Select] day VARCHAR( 2 ) NOT NULL , month VARCHAR( 4 ) NOT NULL , year VARCHAR( 4 ) NOT NULL , is this correct? many thanks Since I didn't want to type it out myself I wrote a small Date of Birth drop down menu generator. Now I'm wondering how I can make the code copy-able in a text area? The script should be inserting all the code ready and finished into a textarea so you can copy and go. How is it done? Here's the script: <?php echo "<center>"; ?> <form action='' method='POST'> <input type='submit' name='submit' /> </form> <?php $submit = $_POST['submit']; if ($submit) { echo "<form action='' method='POST'>"; echo "<select name='month'>"; for ($m = 01; $m <= 12; $m++) { echo " <option value='" . $m . "'>" . $m . "</option> "; } echo "</select>"; echo "<select name='day'>"; for ($d = 01; $d <= 31; $d++) { echo " <option value='" . $d . "'>" . $d . "</option> "; } echo "</select>"; echo "<select name='year'>"; for ($y = 1900; $y <= 2010; $y++) { echo " <option value='" . $y . "'>" . $y . "</option> "; } echo "</select>"; echo "</form>"; echo "</center>"; } ?> So this is a simple code that finds out the difference between two dates and displays it in number of days. $date1=date_create("2013-03-15"); $date2=date_create("2013-12-12"); $diff=date_diff($date1,$date2); echo $diff->format("%R%a days"); // RESULT +272 days
My first question. Is it possible to remove the + sign in the result above? Second question. Is it possible to show "months" if it's greater than 30 days? And years if the days are greater than 365? How would I do this? Hi there, im trying to create a sign up page for my site! I have used confirm password and email fields on the form but the code still shows the error message even if the passwords and emails match! Can anyone advice me please? Please help me out with sessions . I m new to this topic.
so the user is reading a story, to finish reading he has to click a link that redirects them to the signup page. Code: [Select] <?php session_start(); $beginurl = $_SERVER['HTTP_REFERER']; $_SESSION['beginurl'] = $beginurl; echo $_SESSION['beginurl']; ?> <html> <head> </head> <body> <script type="text/javascript"><!-- location.replace("http://www.mysite.com/members/"); //--></script> </body> </html> When they get to the second page, they have to click a link that opens up a modal. this is the code that runs when they hit the register button Code: [Select] session_start(); $beginurl = $_SESSION['beginurl']; $beginurl= (isset($_SESSION['beginurl'])) ? $_SESSION['beginurl'] : 'Error'; if( $_SESSION['status'] ='authorized') $_SESSION['$makemodal'] = 0; //sends the user to the page upon successful password credential if(!isset($_SESSION['SESS_USERID'])||(trim($_SESSION['SESS_USERID']=='admin'))) { echo '<script language="javascript">'; echo "top.location.href = $beginurl"; echo '</script>'; exit(); } Am I passing this variable correctly? and I'm not sure if the top.location.href towards the bottom is correct either, right now after I hit the register button I'm redirected to a blank page where the url is, "http://www.mysite.com/function Error() { [native code]}" I have PHP code that generates a long list of Birth Years in a Drop-down list, and I want to make the control "sticky". I know how to make something like this sticky - thanks to help from you guys... Code: [Select] <!-- Gender --> <label for="gender">Gender:</label> <select id="gender" name="gender"> <option value="">--</option> <option value="F"<?php echo (isset($gender) && $gender == "F") ? 'selected="selected"' : ''; ?>>Female</option> <option value="M"<?php echo (isset($gender) && $gender == "M") ? 'selected="selected"' : ''; ?>>Male</option> </select> But my Birth Year code is a little more complex and I'm racking me brain how to do it... Code: [Select] <!-- Birth Year --> <label for="birthYear">Year Born:</label> <select id="birthYear" name="birthYear"> <option value="">--</option> <?php // Display dates for Users between 18 and 100. for($i = $newestYear; $i >= $oldestYear; $i--){ echo '<option value="' . $i . '">' . $i . '</option>'; } ?> </select> How do I make this second set of code "sticky"?? Thanks, Debbie Hi, We currently have an RSA key in XML format, and am trying to sign it with PHP and phpseclib, however we are struggling to do it. We have managed to decrypt and encrypt it, but can not find a way to sign it. They key has been generated with .NET. Cheers why does this : $date = date('m d,Y', "$postdate");() work to format my date output on one page yet on the other I get the dec 31 1969 output for all my dates? I have this function where i want to pass the month and year according to the date drop down that is chosen by the user. But can't seem to get the selected month and year. But instead, i got the month and year for now (which is April 2020). Can any one show me how can i achive this? I mean how can i pass the month and year selected to my `allreport-summary.php` page. It would be better if you guys can show me examples of codes on how can i implement this. Any help will be appreciated. Thank you so much. cheers!
<div class="row"> <div class="col-4 my-auto"> <input type="month" id="month" class="form-control" value="<?php echo date('Y-m'); ?>"> </div> <div class="col-4 my-auto"> <select class="form-control" id="seller"> <option value="">Select All</option> <?php $sql = "SELECT * FROM sellers ORDER BY seller_registered"; $query = $conn->query($sql); while ($row = $query->fetch_assoc()) { ?> <option value="<?php echo $row['id'];?>"><?php echo $row['seller_fullname'];?></option> <?php } ?> </select> </div> <div class="col-4"> <button type="button" class="btn btn-info" onclick="loadreports();"> <i class="nc-icon nc-zoom-split"></i> </button> <a href="allreport-summary.php?month=<?php echo date('Y-m');?>"> <button type="button" class="btn btn-info" style="height: 40px;"> <i class="fa fa-file-excel-o"></i> Export All Report </button> </a> </div>
So this is how the data is returned for the API I'm using:
REC INFO[p!]=p EXP DATE[p43]=03-20-15 PCODE1[p44]=1 PCODE2[p45]=uSo I'm trying to filter on either of the keys like 'PCODE2[p45]' or 'PCODE1[p44]'.. I'm trying to get the value after the equal sign, but still remain on the same line. So if I were searching by the p45 key, I would get 'u'. If I was searching by the p44 key I would get 1.. Is there a simple regex or something that would allow me to achieve these results? Thank you for any help! Hello, The number sign does not seem to be showing up after a GET request. I've set up a script for an example: text.php: Code: [Select] <?php session_start(); mysql_connect("localhost", "*****", "*******************9") or die(mysql_error()); mysql_select_db("*****") or die(mysql_error()); function safe($var) { $var=mysql_real_escape_string(addslashes(htmlspecialchars($var, ENT_QUOTES, 'UTF-8'))); return $var; } $N=safe($_GET['N']); echo"$N"; ?> Say the url is text.php?N=### None of the symbols show up. Thankyou, GB. Okay, here's what I'm doing. It's sort of like a market script. When someone wants to buy something, they choose from a drop down the item they wish to buy. However, there is a setup cost for it to be started. Then, based upon the length they choose (anywhere from 1 - 12 months), the cost will add up. My questions a Is it possible to assign a setup cost? How can I make it so that, while some things will be, say $2 a month, others will be $3 or other amounts? Here's what I have so far, to try and figure this out. Feel free to laugh... Or if you could point me to an example of something like this, I'd be very appreciative! Thanks!! function ChangeInitialCost(){ $cic = ($_POST['newpremium']); if (($cic == "clan") || ($cic == "guild") || ($cic == "house") || ($cic == "militia")){ } And the form I have: (I haven't entered a submit button yet...) Code: [Select] <table width="200" border="1"> <form action="premium.php" method="post" name="purchase"> <tr> <td>Premium:</td> <td><select id="newpremium" name="newpremium"> <option value="casino">Casino</option> <option value="clan">Clan</option> <option value="guild">Guild</option> <option value="house">House</option> <option value="militia">Militia</option> </select></td></form> </tr> <tr><form action="premium.php" method="post" name="length"> <td>Length:</td> <td><select id="length" name="length"> <option value="0">-----</option> <option value="1">One Month</option> <option value="2">Two Months</option> <option value="3">Three Months</option> <option value="4">Four Months</option> <option value="5">Five Months</option> <option value="6">Six Months</option> <option value="7">Seven Months</option> <option value="8">Eight Months</option> <option value="9">Nine Months</option> <option value="10">Ten Months</option> <option value="11">Eleven Months</option> <option value="12">Twelve Months</option> </select></td></form> </tr> <tr> <td>Cost:</td> <td>SOME TYPE OF FUNCTION</td> </table> |