-
Posts
2,527 -
Joined
-
Last visited
Everything posted by DeanWhitehouse
-
soz for bumping , but anyone?
-
try this <?php session_start(); //This file contains the whole script. // File: includes/functions.php function db_connect() { $host = 'localhost'; $user = 'root'; $password = ''; $database = 'test'; $connection = mysql_connect($host,$username,$password); $database = mysql_select_db($database, $connection); if($connection && $database) { return true; } else { $error = "Error while executing the query"; return $error; } } //File .../Login.php include('includes/functions.php'); if (isset($_POST['submit'])) { echo db_connect(); $username = $_POST['username']; $password = md5($_POST['password']); $tmp = mysql_query('SELECT username FROM users WHERE username = "$username" AND password = "$password"') or die(mysql_error()); $num = mysql_num_rows($tmp) or die(mysql_error()); if ($num < 0 or $num > 1) { exit("Wrong login information. Please try again."); } $tmp = mysql_query('SELECT staff FROM users WHERE username = "$username"') or die(mysql_error()); switch($tmp) { case "1"; $_SESSION['user'] = $_POST['username']; $_SESSION['permissions'] = "1"; break; case "2"; $_SESSION['user'] = $_POST['username']; $_SESSION['permissions'] = "2"; break; default: break; } echo '<meta HTTP-EQUIV= "REFRESH" content="0"; url=http://localhost/index.php">'; } else { echo "No data entered. Please return and enter your login information in the required fields.";//i dont like print } //////////////////////////////////////////////////////////// end. /////////////////////////////////////////////// ?>
-
check if anything is being posted, and check if the post names are correct $_POST['post_name']; <input name="Post_name">
-
Yes, i assumed you were checking to see if the session wasnt there, by checking to see if it exists (if not do) But no problem, remeber session start, also maybe update your learning resource (for sessions anyways) Edit: Click solved at the bottom :
-
Where is session start? It is not on the page where the session is created.
-
<?php if($count=="1"){ session_register("myusername"); header("location: http://www.mysite.com/index.php"); } else { header("location: http://www.mysite.com/home.php?type=841927408208"); } ?> Where is session start? also this is outdated i think , change session_register("myusername"); to $_SESSION['session_name'] = $value; and change if(!session_is_registered(myusername)){ to if(!isset($_SESSION['session_name'])){
-
yes, session_id(); will be different everytime, because its a temporary id from session start (i beleive) And yes ,session_start(); must be on every single page, everyone (other wise the person will go to one and there session will be destroyed)
-
OK, then so u can have sessions, is the subdirectory the same url e.g. mysite.com/page.php (is the main one then subdirectory is) sub.mysite.com , or is it mysite.com/folder/index.php. If its sub.mysite.com i dont think sessions will pass through, also are you sure you are echoing the right session name , and if it has anything stored on it , try error_reporting(E_ALL); at the top.
-
You have put session_start(); on everypage? Also try doing echo session_id(); on the page
-
I have not asked for help in coding for a while now , but i am really stuck on this one. I have the below code which checks each submitted checkbox against the database , then if there is a conflict (where the person already booked time in that area in that time) they get redirected, but the problem i am having is that i dont know how to work with checkboxes. This is the code, i explained quite badly , so you will probably work out more from the code. <?php if(isset($_POST['submit2'])) { $price = $_POST["grandtotal"]; if(isset($_SESSION["email"])) { $frmemail = $_SESSION["email"]; } else { echo "Error. Please login again."; header("Location:home-pub.php?logout"); } $now = date("d/m/Y"); $next = date('d/m/y', strtotime("+1 year")); if($price == 0 || strlen($price) == 0) { echo "Invalid price"; } else { $county = array(); $county = array(150); $m = 0; for($i=0;$i<120;$i++) { $checkbx = isset($_POST['countybox' . $i]); if ($checkbx != '') { $county[$m] = $checkbx; $m++; } } $now = date("d/m/Y"); $next = date('d/m/Y', strtotime("+1 year")); foreach($county as $count) { $query = "SELECT * FROM Payments WHERE Region='".$count."' AND location='WEBSITE'"; $mysql = mysql_query($query); echo $count; while($rw = mysql_fetch_assoc($mysql)) { $startdate = date("d/m/Y",strtotime($rw['periodstart'])); echo $startdate; $enddate = date("d/m/Y",strtotime($rw['periodend'])); //if($startdate =< $now } } } } ?> Then the form <form method="post" action="" name="timereg" onSubmit="return verifyRegister(this.form)"> <?php $now = date("d/m/Y"); $next = date('d/m/Y', strtotime("+1 year")); ?> <p class="para">Please choose the areas you would like to appear in below, for a one year listing period (<?php echo $now." - ".$next;?>).</p> <input type="hidden" value="<?php echo $now;?>" name="1yrstartdate"> <input type="hidden" value="<?php echo $next; ?>" name="1yrenddate"> <input value="<?php echo $rows['companyname'];?>" type="hidden"> <table border="1" cellpadding="4" cellspacing="0" width="440" style="border-collapse:collapse; BORDER: 1px #aa9498; border-style: solid; margin-top: 0px; margin-bottom: 16px;margin-left: 4px;"><tr><td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1"> <input type="checkbox" name="countyboxENGLAND" value="NA" onClick="englandCheck()"> <b>England</b><br><br> <input type="checkbox" name="countybox1" value="Bedfordshire" onClick="countyCount(this)"> Bedfordshire<br> <input type="checkbox" name="countybox2" value="Berkshire" onClick="countyCount(this)"> Berkshire<br> <input type="checkbox" name="countybox3" value="Buckinghamshire" onClick="countyCount(this)"> Buckinghamshire<br> <input type="checkbox" name="countybox4" value="Cambridgeshire" onClick="countyCount(this)"> Cambridgeshire<br> <input type="checkbox" name="countybox5" value="Cheshire" onClick="countyCount(this)"> Cheshire<br> <input type="checkbox" name="countybox6" value="Cornwall" onClick="countyCount(this)"> Cornwall<br> <input type="checkbox" name="countybox7" value="Cumberland" onClick="countyCount(this)"> Cumberland<br> <input type="checkbox" name="countybox8" value="Derbyshire" onClick="countyCount(this)"> Derbyshire<br> <input type="checkbox" name="countybox9" value="Devon" onClick="countyCount(this)"> Devon<br> <input type="checkbox" name="countybox10" value="Dorset" onClick="countyCount(this)"> Dorset<br> <input type="checkbox" name="countybox11" value="Durham" onClick="countyCount(this)"> Durham<br> <input type="checkbox" name="countybox12" value="Essex" onClick="countyCount(this)"> Essex<br> </td> <td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top"> <input type="checkbox" name="countybox13" value="Gloucestershire" onClick="countyCount(this)"> Gloucestershire<br> <input type="checkbox" name="countybox14" value="Hampshire" onClick="countyCount(this)"> Hampshire<br> <input type="checkbox" name="countybox15" value="Herefordshire" onClick="countyCount(this)"> Herefordshire<br> <input type="checkbox" name="countybox16" value="Hertfordshire" onClick="countyCount(this)"> Hertfordshire<br> <input type="checkbox" name="countybox17" value="Huntingdonshire" onClick="countyCount(this)"> Huntingdonshire <br> <input type="checkbox" name="countybox19" value="Lancashire" onClick="countyCount(this)"> Lancashire<br> <input type="checkbox" name="countybox20" value="Leicestershire" onClick="countyCount(this)"> Leicestershire<br> <input type="checkbox" name="countybox21" value="Lincolnshire" onClick="countyCount(this)"> Lincolnshire<br> <input type="checkbox" name="countybox22" value="Middlesex" onClick="countyCount(this)"> Middlesex<br> <input type="checkbox" name="countybox23" value="Norfolk" onClick="countyCount(this)"> Norfolk<br> <input type="checkbox" name="countybox24" value="Northamptonshire" onClick="countyCount(this)"> Northamptonshire<br> <input type="checkbox" name="countybox25" value="Northumberland" onClick="countyCount(this)"> Northumberland<br> <input type="checkbox" name="countybox26" value="Nottinghamshire" onClick="countyCount(this)"> Nottinghamshire<br> </td> <td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top"> <input type="checkbox" name="countybox27" value="Oxfordshire" onClick="countyCount(this)"> Oxfordshire<br> <input type="checkbox" name="countybox28" value="Rutland" onClick="countyCount(this)"> Rutland<br> <input type="checkbox" name="countybox29" value="Shropshire" onClick="countyCount(this)"> Shropshire<br> <input type="checkbox" name="countybox30" value="Somerset" onClick="countyCount(this)"> Somerset<br> <input type="checkbox" name="countybox31" value="Staffordshire" onClick="countyCount(this)"> Staffordshire<br> <input type="checkbox" name="countybox32" value="Suffolk" onClick="countyCount(this)"> Suffolk<br> <input type="checkbox" name="countybox33" value="Surrey" onClick="countyCount(this)"> Surrey<br> <input type="checkbox" name="countybox34" value="Sussex" onClick="countyCount(this)"> Sussex<br> <input type="checkbox" name="countybox35" value="Warwickshire" onClick="countyCount(this)"> Warwickshire<br> <input type="checkbox" name="countybox36" value="Westmorland" onClick="countyCount(this)"> Westmorland<br> <input type="checkbox" name="countybox37" value="Wiltshire" onClick="countyCount(this)"> Wiltshire<br> <input type="checkbox" name="countybox38" value="Worcestershire" onClick="countyCount(this)"> Worcestershire<br> <input type="checkbox" name="countybox39" value="Yorkshire" onClick="countyCount(this)"> Yorkshire<br> </td></tr></table> <table border="1" cellpadding="4" cellspacing="0" width="440" style="border-collapse:collapse; BORDER: 1px #aa9498; border-style: solid; margin-top: 0px; margin-bottom: 16px;margin-left: 4px;"><tr><td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top"> <input type="checkbox" name="countyboxSCOTLAND" value="NA" onClick="scotlandCheck()"> <b>Scotland</b><br><br> <input type="checkbox" name="countybox40" value="Aberdeenshire" onClick="countyCount(this)"> Aberdeenshire<br> <input type="checkbox" name="countybox41" value="Angus" onClick="countyCount(this)"> Angus<br> <input type="checkbox" name="countybox42" value="Argyll" onClick="countyCount(this)"> Argyll<br> <input type="checkbox" name="countybox43" value="Ayrshire" onClick="countyCount(this)"> Ayrshire<br> <input type="checkbox" name="countybox44" value="Banffshire" onClick="countyCount(this)"> Banffshire<br> <input type="checkbox" name="countybox45" value="Berwickshire" onClick="countyCount(this)"> Berwickshire<br> <input type="checkbox" name="countybox46" value="Bute (islands of Arran and Bute)" onClick="countyCount(this)"> Bute (islands of Arran and Bute)<br> <input type="checkbox" name="countybox47" value="Caithness" onClick="countyCount(this)"> Caithness<br> <input type="checkbox" name="countybox48" value="Clackmannanshire" onClick="countyCount(this)"> Clackmannanshire<br> <input type="checkbox" name="countybox49" value="Dumfriesshire" onClick="countyCount(this)"> Dumfriesshire<br> <input type="checkbox" name="countybox50" value="Dunbartonshire" onClick="countyCount(this)"> Dunbartonshire<br> <input type="checkbox" name="countybox51" value="East Lothian" onClick="countyCount(this)"> East Lothian<br> </td> <td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top"> <input type="checkbox" name="countybox52" value="Fife" onClick="countyCount(this)"> Fife<br> <input type="checkbox" name="countybox53" value="Forfarshire (see Angus)" onClick="countyCount(this)"> Forfarshire (see Angus)<br> <input type="checkbox" name="countybox54" value="Inverness-shire (includes Lewis (part), Uist & Skye)" onClick="countyCount(this)"> Inverness-shire<br>(includes Lewis (part), Uist & Skye)<br> <input type="checkbox" name="countybox55" value="Kincardineshire" onClick="countyCount(this)"> Kincardineshire<br> <input type="checkbox" name="countybox56" value="Kinross-shire" onClick="countyCount(this)"> Kinross-shire<br> <input type="checkbox" name="countybox57" value="Kirkcudbrightshire" onClick="countyCount(this)"> Kirkcudbrightshire<br> <input type="checkbox" name="countybox58" value="Lanarkshire" onClick="countyCount(this)"> Lanarkshire<br> <input type="checkbox" name="countybox59" value="Midlothian" onClick="countyCount(this)"> Midlothian<br> <input type="checkbox" name="countybox60" value="Moray" onClick="countyCount(this)"> Moray<br> <input type="checkbox" name="countybox61" value="Nairnshire" onClick="countyCount(this)"> Nairnshire<br> <input type="checkbox" name="countybox62" value="Orkney" onClick="countyCount(this)"> Orkney<br> <input type="checkbox" name="countybox63" value="Peeblesshire" onClick="countyCount(this)"> Peeblesshire<br> </td> <td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top"> <input type="checkbox" name="countybox64" value="Perthshire" onClick="countyCount(this)"> Perthshire<br> <input type="checkbox" name="countybox65" value="Renfrewshire" onClick="countyCount(this)"> Renfrewshire<br> <input type="checkbox" name="countybox66" value="Ross & Cromarty (includes part of Lewis)" onClick="countyCount(this)"> Ross & Cromarty<br>(includes part of Lewis)<br> <nobr><input type="checkbox" name="countybox67" value="Roxburghshire" onClick="countyCount(this)"> Roxburghshire</nobr><br> <input type="checkbox" name="countybox68" value="Selkirkshire" onClick="countyCount(this)"> Selkirkshire<br> <input type="checkbox" name="countybox69" value="Shetland" onClick="countyCount(this)"> Shetland<br> <input type="checkbox" name="countybox70" value="Stirlingshire" onClick="countyCount(this)"> Stirlingshire<br> <input type="checkbox" name="countybox71" value="Sutherland" onClick="countyCount(this)"> Sutherland<br> <input type="checkbox" name="countybox72" value="West Lothian" onClick="countyCount(this)"> West Lothian<br> <input type="checkbox" name="countybox73" value="Wigtownshire" onClick="countyCount(this)"> Wigtownshire<br><br> </td></tr></table> <table border="1" cellpadding="4" cellspacing="0" width="440" style="border-collapse:collapse; BORDER: 1px #aa9498; border-style: solid; margin-top: 0px; margin-bottom: 16px;margin-left: 4px;"><tr><td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top"> <input type="checkbox" name="countyboxWALES" value="NA" onClick="walesCheck()"> <b>Wales</b><br><br> <input type="checkbox" name="countybox74" value="Anglesey" onClick="countyCount(this)"> Anglesey<br> <input type="checkbox" name="countybox75" value="Breconshire" onClick="countyCount(this)"> Breconshire<br> <input type="checkbox" name="countybox76" value="Caernarvonshire" onClick="countyCount(this)"> Caernarvonshire<br> <input type="checkbox" name="countybox77" value="Cardiganshire" onClick="countyCount(this)"> Cardiganshire<br> <input type="checkbox" name="countybox78" value="Carmarthenshire" onClick="countyCount(this)"> Carmarthenshire<br> <input type="checkbox" name="countybox79" value="Denbighshire" onClick="countyCount(this)"> Denbighshire<br> <input type="checkbox" name="countybox80" value="Flintshire" onClick="countyCount(this)"> Flintshire<br> <input type="checkbox" name="countybox81" value="Glamorgan" onClick="countyCount(this)"> Glamorgan<br> </td><td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top"> <input type="checkbox" name="countybox82" value="Merionethshire" onClick="countyCount(this)"> Merionethshire<br> <input type="checkbox" name="countybox83" value="Monmouthshire" onClick="countyCount(this)"> Monmouthshire<br> <input type="checkbox" name="countybox84" value="Montgomeryshire" onClick="countyCount(this)"> Montgomeryshire<br> <input type="checkbox" name="countybox85" value="Pembrokeshire" onClick="countyCount(this)"> Pembrokeshire<br> <input type="checkbox" name="countybox86" value="Radnorshire" onClick="countyCount(this)"> Radnorshire<br> <br><br> <input type="checkbox" name="countyboxCHANNEL" value="NA" onClick="channelCheck()"> <b>Channel Islands</b><br><br> <input type="checkbox" name="countybox87" value="Channel Islands" onClick="countyCount(this)"> Channel Islands<br> </td></tr></table> <table border="1" cellpadding="4" cellspacing="0" width="440" style="border-collapse:collapse; BORDER: 1px #aa9498; border-style: solid; margin-top: 0px; margin-bottom: 16px;margin-left: 4px;"><tr><td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top"> <input type="checkbox" name="countyboxIRELAND" value="NA" onClick="irelandCheck()"> <b>Ireland</b><br><br> <input type="checkbox" name="countybox88" value="Antrim" onClick="countyCount(this)"> Antrim<br> <input type="checkbox" name="countybox89" value="Armagh" onClick="countyCount(this)"> Armagh<br> <input type="checkbox" name="countybox90" value="Carlow" onClick="countyCount(this)"> Carlow<br> <input type="checkbox" name="countybox91" value="Cavan" onClick="countyCount(this)"> Cavan<br> <input type="checkbox" name="countybox92" value="Clare" onClick="countyCount(this)"> Clare<br> <input type="checkbox" name="countybox93" value="Cork" onClick="countyCount(this)"> Cork<br> <input type="checkbox" name="countybox94" value="Donegal" onClick="countyCount(this)"> Donegal<br> <input type="checkbox" name="countybox95" value="Down" onClick="countyCount(this)"> Down<br> <input type="checkbox" name="countybox96" value="Dublin" onClick="countyCount(this)"> Dublin<br> <input type="checkbox" name="countybox97" value="Fermanagh" onClick="countyCount(this)"> Fermanagh<br> <input type="checkbox" name="countybox98" value="Galway" onClick="countyCount(this)"> Galway<br> <input type="checkbox" name="countybox99" value="Kerry" onClick="countyCount(this)"> Kerry<br> <input type="checkbox" name="countybox100" value="Kildare" onClick="countyCount(this)"> Kildare<br> <input type="checkbox" name="countybox101" value="Kilkenny" onClick="countyCount(this)"> Kilkenny<br> <input type="checkbox" name="countybox102" value="Londonderry" onClick="countyCount(this)"> Londonderry<br> </td><td style="BORDER: 1px #aa9498; border-style: solid; padding: 6pt;" bgcolor="#ffffe1" valign="top"> <input type="checkbox" name="countybox103" value="Leitrim" onClick="countyCount(this)"> Leitrim<br> <input type="checkbox" name="countybox104" value="Leix" onClick="countyCount(this)"> Leix<br> <input type="checkbox" name="countybox105" value="Limerick" onClick="countyCount(this)"> Limerick<br> <input type="checkbox" name="countybox106" value="Longford" onClick="countyCount(this)"> Longford<br> <input type="checkbox" name="countybox107" value="Louth" onClick="countyCount(this)"> Louth<br> <input type="checkbox" name="countybox108" value="Mayo" onClick="countyCount(this)"> Mayo<br> <input type="checkbox" name="countybox109" value="Meath" onClick="countyCount(this)"> Meath<br> <input type="checkbox" name="countybox110" value="Monaghan" onClick="countyCount(this)"> Monaghan<br> <input type="checkbox" name="countybox111" value="Offaly" onClick="countyCount(this)"> Offaly<br> <input type="checkbox" name="countybox112" value="Roscommon" onClick="countyCount(this)"> Roscommon<br> <input type="checkbox" name="countybox113" value="Sligo" onClick="countyCount(this)"> Sligo<br> <input type="checkbox" name="countybox114" value="Tipperary" onClick="countyCount(this)"> Tipperary<br> <input type="checkbox" name="countybox115" value="Tyrone" onClick="countyCount(this)"> Tyrone<br> <input type="checkbox" name="countybox116" value="Waterford" onClick="countyCount(this)"> Waterford<br> <input type="checkbox" name="countybox117" value="Westmeath" onClick="countyCount(this)"> Westmeath<br> <input type="checkbox" name="countybox118" value="Wexford" onClick="countyCount(this)"> Wexford<br> <input type="checkbox" name="countybox119" value="Wicklow" onClick="countyCount(this)"> Wicklow<br> </td></tr></table> <p class="para"> <input type="text" name="multicountybox" value="Choose 2 or more regions for a £100 discount" style="border:0px;cursor:default;background:#f5d5da;width:360"><br><br> Total Price: £<input name="grandtotal" type="text" onFocus="this.blur()" size="12" value="0" style="text-align:center;cursor:default"> <nobr><input name="truepricebox" type="text" size="6" style="border:0px;text-align:right;cursor:default;background:#f5d5da" value="(£0"> per county)</nobr></p> <img src="img/blank.gif" name="regionmap" alt=""> <p class="para"><input type="checkbox" name="terms"> Please tick this box to verify that you agree to our standard <a href="javascript:void(0);" onClick="popTerms()">terms & conditions</a>.<br> <br> <input type="submit" value="Submit entry" class="inputbox" name="submit2"> </p> </form> When i echo out the the $count , it just says 1 for each one , not the value. Any help please..
-
If you look at it logically , you are saying if variable one doesnt equal empty , then do if($var != '') or if empty doesnt equal variable one , then do if('' != $var)
-
No putting the var after, wouldnt be the same as putting it before. e.g. if($var != '') is not the same as if('' != $var) As they will return different results , so i think.
-
[SOLVED] New Cryptic Login , confusing style
DeanWhitehouse replied to DeanWhitehouse's topic in PHP Coding Help
Given Up. ??? -
This will help http://uk3.php.net/manual/en/language.operators.comparison.php
-
[SOLVED] Why isn't My Database Updating ?
DeanWhitehouse replied to god_zun's topic in PHP Coding Help
Ok, click solved at the bottom of the page. Also try out some tutorials here http://www.w3schools.com/PHP/ and http://www.tizag.com/phpT/ -
[SOLVED] Why isn't My Database Updating ?
DeanWhitehouse replied to god_zun's topic in PHP Coding Help
where is $ID defined?? WHERE ID='$ID'" -
I really doudt there are any free ones , you may have to go for cheap instead of free.
-
Google ?? http://www.google.co.uk/search?q=php+send+sms&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-GB:official&client=firefox-a http://www.ozekisms.com/php-sms-api-asp-sms-api/index_p_php_q_ow_page_number_e_327opt.html
-
[SOLVED] Why isn't My Database Updating ?
DeanWhitehouse replied to god_zun's topic in PHP Coding Help
omg, PLEASE read what i wrote above about post values ^^, then fix your code . -
Then here are two functions http://uk.php.net/manual/en/function.eregi-replace.php http://uk.php.net/preg_replace
-
To repopulate the fields do (if you are using post) <input type="text" value="<?php if(isset($_POST['field1'])) {echo $_POST['field1'];} ?>" name="field1">
-
Impossible ?? Too Ambitious ?? Plain Crazy??
DeanWhitehouse replied to DeanWhitehouse's topic in PHP Coding Help
Ok, thanks i will have a look at that . -
If you dont want help ,dont ask , i provided a way for it to be done.
-
Show us what you have already?
-
^^ doesnt make much sense, read over str_replace it should do all of that.