![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#21 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 30
OS: xp sp3
|
Re: Mysql database and php
This is my validateuser page that process the from from the login page (This works)
PHP Code:
<head> <title></title> <link rel="stylesheet" href="../css/style2.css" type="text/css" charset="utf-8" /> </head> <body bgcolor="#694545;"> PHP Code:
However, when i set the session below, my guess is that it parses false and goes back to the validateuser(login) page..... When i removed the session details, only then i can go to the welcome page.... I can't seem to figure out why the 'session empty' is saying true, even though the login credentials are fine.... :( This is my Welcome Page.... HTML Code:
<?php session_start(); if(empty($_SESSION['login'])) { header ("Location: login.php"); } ?> <html> <head> <title>AEW | WELCOME</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="../style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="../js/form.js"></script> </head> <body> <div id="container"> <div id="banner"><h1>Adult Educational Website</h1></div> <div id="navcontainer"> <ul id="navlist"> <li id="active"><a id="current" href="http://www.techsupportforum.com/design-forum/index.html">Homepage</a></li> <li><a href="http://www.techsupportforum.com/design-forum/upload.html">Upload Assignments</a></li> <li><a href="courses.php">View All Courses</a></li> <li><a href="http://www.techsupportforum.com/design-forum/contact_us.html">Contact Us</a></li> </ul> </div> <div class="intro"> <h2>Welcome to <span style="font-weight:bold; color:#069;">I-Edu</span></h2> <p><img class="imgleft" src="http://www.techsupportforum.com/design-forum/img/orb.png" alt="icon" title="icon" /> <strong>This is the First website of its kind, here you can upload your assignments.</strong> </p> <p>» <a href="#">Read more</a></p> </div> <div class="separator"></div> <div class="intro2"><h2>Personalize</h2> <p><img class="imgleft" src="http://www.techsupportforum.com/design-forum/img/orb.png" alt="icon" title="icon" /> Please register to gain free access to thousands of journals and other resources... </p> <p>» <a href="#">Read more</a> </p></div> <div class="intro3"><h2>Uploading Assigments</h2> <p><img class="imgleft" src="http://www.techsupportforum.com/design-forum/img/orb.png" alt="icon" title="icon" /> We are a small school located in Central London...</p> <p>» <a href="#">Read more</a> </p></div> <div style="clear:both;"></div> <div id="sidebar"> <h1>News</h1> <p> Earn your degree online, <br />coming soon !!!</p> <h1>Links </h1> <ul> <li><a href="#">Snapp Happy</a></li> <li><a href="#" title="The Open Design Community">TODC</a></li> <li><a href="#">Andreas Viklund</a></li> <li><a href="#">James Koster</a> </li> <li><a href="#">OSWD</a></li> <li><a href="#"> CSS play </a></li> <li><a href="#" title="CSS menus">Listamatic </a></li> </ul> </div> <div id="content"> <table style="bordercolor:#FFFFFF; bordercolorlight:#C0C0C0; bordercolordark:#808080; bgcolor:#FFFFFF" border="0" width="70%" cellspacing="0" cellpadding="0"> <tr> <td style="bordercolor:#000000; bordercolorlight:#000000; bordercolordark:#000000; bgcolor:#000000"> <?php print "Welcome, {$_SESSION['student_fname']} {$_SESSION['student_lname']}!"; print "and thanks for registering, you can feel free to enjoy any content on this site.!!" ?> ] <br /><br />Regards,<br />The University Web Team </td> </tr> </table> </div> <div id="footer"> <a href="#">homepage</a> | <a href="mailto:">contact</a> | <a href="http://validator.w3.org/check?uri=referer">html</a> | <a href="http://jigsaw.w3.org/css-validator">css</a> | © 2007 </div> </div> </body> </html> <?php ?> [[Moderator's Note: please use [php] and [html] as Redcore suggested.]]
Last edited by dm01; 11-21-2009 at 02:06 PM. |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#22 (permalink) |
|
Design Team Member
|
Re: Mysql database and php
It doesn't appear that you're setting the LOGIN session variable, but rather just the "student_id" session variable.
PS in PHP5 you don't need to register session variables ;)
__________________
Free Resources PC Protection - Comodo Firewall | AVG Anti-Virus | WinPatrol | Ad-Aware | Spybot S&D | SpywareBlaster |Web Design/Programming - KompoZer (Editor) | Paint.NET (Graphic) | GIMP+GIMPShop (Graphic) | FileZilla (FTP Client) | Free Hosting | |
|
|
|
|
|
#23 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 30
OS: xp sp3
|
Re: Mysql database and php
lol...waw, now i'm more at a loss....lol
Do mean this line of code? PHP Code:
If so, how do I then integrate the Login session variable??...i'm stumped... :( |
|
|
|
|
|
#24 (permalink) |
|
Design Team Member
|
Re: Mysql database and php
In your validation you're trying to see if the session variable "login" exists - if you don't set it, it will always send it back to the login page.
Your code should *theoretically* look more like this: PHP Code:
PHP Code:
__________________
Free Resources PC Protection - Comodo Firewall | AVG Anti-Virus | WinPatrol | Ad-Aware | Spybot S&D | SpywareBlaster |Web Design/Programming - KompoZer (Editor) | Paint.NET (Graphic) | GIMP+GIMPShop (Graphic) | FileZilla (FTP Client) | Free Hosting | |
|
|
|
|
|
#25 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 30
OS: xp sp3
|
Re: Mysql database and php
Crystal clear Redcore!!! but...lol..i'm still having the same problem, with both examples.....all
after making validation changes, all i have atop the protected page is PHP Code:
|
|
|
|
|
|
#26 (permalink) |
|
Design Team Member
|
Re: Mysql database and php
Hmm. Works for me. Do you have "session_start();" at the top of your login page?
__________________
Free Resources PC Protection - Comodo Firewall | AVG Anti-Virus | WinPatrol | Ad-Aware | Spybot S&D | SpywareBlaster |Web Design/Programming - KompoZer (Editor) | Paint.NET (Graphic) | GIMP+GIMPShop (Graphic) | FileZilla (FTP Client) | Free Hosting | |
|
|
|
|
|
#27 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 30
OS: xp sp3
|
Re: Mysql database and php
yeah i do... see below my login page (validateuser.php)
PHP Code:
PHP Code:
|
|
|
|
|
|
#28 (permalink) |
|
Design Team Member
|
Re: Mysql database and php
Let's go through your login script. It seems to have a lot of security holes and various practices I'm unclear about.
A) Why is your "getData" function empty? Doesn't seem to actually do anything. B) Never put non-sanitized user-defined variables into anything, especially database queries. Do that by using mysqli_real_escape_string PHP Code:
Example: PHP Code:
__________________
Free Resources PC Protection - Comodo Firewall | AVG Anti-Virus | WinPatrol | Ad-Aware | Spybot S&D | SpywareBlaster |Web Design/Programming - KompoZer (Editor) | Paint.NET (Graphic) | GIMP+GIMPShop (Graphic) | FileZilla (FTP Client) | Free Hosting | |
|
|
|
|
|
#29 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 30
OS: xp sp3
|
Re: Mysql database and php
sigh....ok..Thanks alot Redcore!!
Maybe i should've mentioned that i'm a newbie and don't really know how to fix the problem, so i'd save alot of time... Please bear with me... :( |
|
|
|
|
|
#30 (permalink) |
|
Design Team Member
|
Re: Mysql database and php
Hah, I gathered that you're new - everyone has to start somewhere :) I'm always totally happy to help so long as the person I'm helping doesn't depend on me - meaning they try to do it themselves a few times before asking. :)
__________________
Free Resources PC Protection - Comodo Firewall | AVG Anti-Virus | WinPatrol | Ad-Aware | Spybot S&D | SpywareBlaster |Web Design/Programming - KompoZer (Editor) | Paint.NET (Graphic) | GIMP+GIMPShop (Graphic) | FileZilla (FTP Client) | Free Hosting | |
|
|
|
|
|
#31 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 30
OS: xp sp3
|
Super cool man!!! Thanks!!! :-)
Hey Redcore, I've come up with this, but it still doesn't work... :( PHP Code:
HTML Code:
<html> <head> <title>TEst</title> <!-- <link rel="stylesheet" href="../style.css" type="text/css" charset="utf-8" /> --> </head> [[Moderator's Note: please do not double-post. Ask a member of staff to edit your original post or merge consecutive postings. Thank you. —dm01]]
Last edited by dm01; 11-21-2009 at 02:09 PM. Reason: merging double-posting |
|
|
|
|
|
#32 (permalink) |
|
Design Team Member
|
Re: Mysql database and php
So long as "<username> doesn't exist" is indeed the error you're receiving, you hard coded that and this is what it's stumbling on:
PHP Code:
A few more notes:
I reworked most of your code (in the login section) so try this out... PHP Code:
__________________
Free Resources PC Protection - Comodo Firewall | AVG Anti-Virus | WinPatrol | Ad-Aware | Spybot S&D | SpywareBlaster |Web Design/Programming - KompoZer (Editor) | Paint.NET (Graphic) | GIMP+GIMPShop (Graphic) | FileZilla (FTP Client) | Free Hosting | |
|
|
|
|
|
#33 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 30
OS: xp sp3
|
Re: Mysql database and php
Hey RedCore, I've managed to get through with the PHP sessions, but i just wanna say thanks man!!!!
I have a simpler problem though? i'm trying to store 'date and time' info in my database, My code so far is From HTML Form Date Required:<select size="1" name="Date" value="dd"> <option selected>day</option> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> <option>24</option> <option>25</option> <option>26</option> <option>27</option> <option>28</option> <option>29</option> <option>30</option> <option>31</option> </select> <select size="1" value="mm"> <option selected>month</option> <option>January</option> <option>February</option> <option>March</option> <option>April</option> <option>May</option> <option>June</option> <option>July</option> <option>August</option> <option>September</option> <option>October</option> <option>November</option> <option>December</option> </select> <select size="1" value="yyyy"> <option selected>year</option> <option>2009</option> <option>2010</option> </select> Time Required: <select name="Time" size="1"> <option value="HH">hh</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select> <select name="Time" size="1"> <option value="MM">mm</option> <option value="00">00</option> <option value="05">05</option> <option value="10">10</option> <option value="15">15</option> <option value="20">20</option> <option value="25">25</option> <option value="30">30</option> <option value="35">35</option> <option value="40">40</option> <option value="45">45</option> <option value="50">50</option> <option value="55">55</option> </select> <select name="Time" size="1"> <option selected>am/pm</option> <option value="AM">AM</option> <option value="PM">PM</option> </select> in my php form i have PHP Code:
The question however is, How can get my html form to store all selected options as ONE date field, to insert into my database (dd-mm-yyyy) ??? I'm stumped.. Thanks alot for ur time.. Randyrr |
|
|
|
|
|
#34 (permalink) |
|
Design Team Member
|
Re: Mysql database and php
You COULD try to use jQuery UI and one of these datetime picker libraries...
http://milesich.com/timepicker/ http://blogs.uct.ac.za/blog/lovemore...te-time-picker But if you want to do it manually, you'd take all those values, pass them individually, and "paste" them together with PHP: PHP Code:
__________________
Free Resources PC Protection - Comodo Firewall | AVG Anti-Virus | WinPatrol | Ad-Aware | Spybot S&D | SpywareBlaster |Web Design/Programming - KompoZer (Editor) | Paint.NET (Graphic) | GIMP+GIMPShop (Graphic) | FileZilla (FTP Client) | Free Hosting | |
|
|
|
|
|
#35 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 30
OS: xp sp3
|
Re: Mysql database and php
THank you so much Redcore,
I got through with the Date/Time thingy!!!! I'm trying to Update a specific row in mysql when the user selects a button from a form in PHP Here goes: PHP Code:
i'm trying to pass the job_id so only that row will be updated.... now here's the rest PHP Code:
my problem is that nothing is parsed at all (even is if say '$formjob_id' or simply '$job_id').....what do u think could be the problem ?? Thanks again, randyrr |
|
|
|
|
|
#36 (permalink) |
|
Design Team Member
|
Re: Mysql database and php
There needs to be a form element to pass it to...
PHP Code:
__________________
Free Resources PC Protection - Comodo Firewall | AVG Anti-Virus | WinPatrol | Ad-Aware | Spybot S&D | SpywareBlaster |Web Design/Programming - KompoZer (Editor) | Paint.NET (Graphic) | GIMP+GIMPShop (Graphic) | FileZilla (FTP Client) | Free Hosting | |
|
|
|
|
|
#37 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 30
OS: xp sp3
|
Hi Redcore,
now the value is passing, but the table does not update.... Could u assist. The same php query above.... Hey RedCore, I figured it out.... i forgot the PHP Code:
randyrr [[--merged from double-posting —dm01]] new problem redcore i want to insert into two separate tables although where the names are the same here's my php code: PHP Code:
[[--merged from double-posting, guess that'd make this a triple post —dm01--]] fixed issue [[Moderator's Note: please try not to make consecutive postings. You can either ask a staff member (via PM) to edit your original post, or to merge consecutive postings. When we have to do it for you we get kind of annoyed. Thank you for helping us keep TSF a nice place for everyone to visit.--]]
Last edited by dm01; 11-21-2009 at 02:13 PM. |
|
|
|
|
|
#38 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 30
OS: xp sp3
|
Re: Mysql database and php
*** fixed previous issue ***
new question What i'm trying to get at is this: there are 3 types of vehicles v1 = 5 seats v2 = 4 seats v3 = 3 seats If the vehicle selected = v1 then 1. check is seating is available 2. create booking 3. decrease the number of available seats until availability = 5 4. display error how to write it in a loop (if, while..do or for ). |
|
|
|
|
|
#39 (permalink) |
|
Design Team Member
|
Re: Mysql database and php
You'd use an array and do a "for" loop to check the amount of available seats, create the booking, and alter the array (to remove a seat).
__________________
Free Resources PC Protection - Comodo Firewall | AVG Anti-Virus | WinPatrol | Ad-Aware | Spybot S&D | SpywareBlaster |Web Design/Programming - KompoZer (Editor) | Paint.NET (Graphic) | GIMP+GIMPShop (Graphic) | FileZilla (FTP Client) | Free Hosting | |
|
|
|
|
|
#40 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 30
OS: xp sp3
|
Re: Mysql database and php
Hey,
This is my js form function FrontPage_Form1_Validator(theForm) { if (theForm.student_fname.value == "") { alert("Please enter your \"First Name\" ."); theForm.student_fname.focus(); return (false); } if (theForm.student_fname.value.length < 3) { alert("Please enter at least 3 characters in the \"First Name\" field."); theForm.student_fname.focus(); return (false); } if (theForm.student_fname.value.length > 20) { alert("Please enter at most 20 characters in the \"First Name\" field."); theForm.student_fname.focus(); return (false); } if (theForm.student_lname.value == "") { alert("Please enter your \"Last Name\" ."); theForm.student_lname.focus(); return (false); } if (theForm.student_lname.value.length < 3) { alert("Please enter at least 3 characters in the \"Last Name\" field."); theForm.student_lname.focus(); return (false); } if (theForm.student_lname.value.length > 20) { alert("Please enter at most 20 characters in the \"Last Name\" field."); theForm.student_lname.focus(); return (false); } if (theForm.student_address_no.value == "") { alert("Please enter your contact \"Address\"."); theForm.student_address_no.focus(); return (false); } if (theForm.student_phone.value == "") { alert("Please enter your contact \"Phone\" number."); theForm.student_phone.focus(); return (false); } if (theForm.student_street_name.value == "") { alert("Please enter your contact \"Phone\" number."); theForm.student_street_name.focus(); return (false); } if (theForm.student_phone.value == "") { alert("Please enter your contact \"Phone\" number."); theForm.student_phone.focus(); return (false); } if (theForm.student_phone.value.length < 7) { alert("Please enter at least 7 characters in the \"Phone\" field."); theForm.student_phone.focus(); return (false); } if (theForm.student_phone.value.length > 10) { alert("Please enter at most 10 characters in the \"Phone\" field."); theForm.student_phone.focus(); return (false); } if (theForm.student_email.value == "") { alert("Please enter your contact \"Email\" address."); theForm.student_email.focus(); return (false); } if (theForm.student_username.value == "") { alert("Please enter your contact \"Email\" address."); theForm.student_username.focus(); return (false); } if (theForm.student_password.value == "") { alert("Please enter your contact \"Email\" address."); theForm.student_password.focus(); return (false); } if (theForm.student_password.value !== theForm.student_password2.value) { alert("Your password does not match"); theForm.student_password.focus(); return (false); } return (true); } how can i check validation against apostrophes (')being entered in the database, as well as proper email validation, using the above script? thanks randyrr |
|
|
|
![]() |
| Thread Tools | |
|
|