PHP - How To Manadatory Checkboxes Without Display Server Error To User
<?php
echo $error_msg=''; if(isset($_POST['submit'])) { $LoginId=$_POST['LoginId']; $Password1=$_POST['Password1']; $Password2=$_POST['Password2']; $Name=$_POST['Name']; $Age=$_POST['Age']; $BloodGroup=$_POST['BloodGroup']; $Sex=$_POST['Sex']; $Qualification=$_POST['Qualification']; $Email=$_POST['Email']; $Address=$_POST['Address']; $AboutYourself=$_POST['AboutYourself']; [b]$countCheck=count($_POST['checkbox']); echo $countCheck;[/b] //$checkbox=$_POST['checkbox']; //$countCheck=count($checkbox); if(empty($LoginId)){echo 'Please enter Login Id';} elseif(empty($Password1)){echo 'Please enter Password';} elseif(empty($Password2)){echo 'Please confirm Password';} elseif($Password1!==$Password2){echo 'Password didn\'t match';} elseif(empty($Name)){echo 'Please enter Name';} elseif(empty($Age)){echo 'Please enter Age';} elseif(empty($Sex)){echo 'Please enter Sex';} elseif(empty($Qualification)){echo 'Please enter Qualification';} elseif(empty($Email)){echo 'Please enter Email';} elseif(empty($Address)){echo 'Please enter Address';} elseif(empty($AboutYourself)){echo 'Please enter About Yourself';} [b]elseif($countCheck==0){ echo 'You have to register at least one activity.';}[/b] else { $dbc=mysqli_connect('localhost','root','','nog'); $query="select * from registration where LoginId='$LoginId'"; $result=mysqli_query($dbc,$query); if(mysqli_num_rows($result)==0) { $checkbox=$_POST['checkbox']; $countCheck=count($_POST['checkbox']); $reg_id=' '; for($i=0;$i<$countCheck;$i++) { $reg_id=$reg_id.$checkbox[$i].','; } $query="insert into registration (LoginId,Password,Name,Age,BloodGroup,Sex,Qualification,Email,Address,AboutYourself,Activity)values ('$LoginId',SHA('$Password1'),'$Name','$Age','$BloodGroup','$Sex','$Qualification','$Email','$Address','$AboutYourself','$reg_id')"; $result=mysqli_query($dbc,$query) or die("Not Connect"); echo ' Dear '.$Name.'.<br>Your Account is waiting for approval<br>'; echo "<a href='RegistrationAndActivity.php'>Back to Home</a>"; //header('Location: index.php'); // header('Location: Registration.php'); } else { echo 'Dear '.$Name. ' <br>Account already exist with Login Id '.$LoginId.' <br>Try another Login Id'; }} } ?> <html> <body> <?php echo $error_msg; ?> <h3>New User?</h3> <form action='<?php echo $_SERVER['PHP_SELF'];?>' method='post'> Enter Login id<br><input type='text' name='LoginId' value='<?php if(!empty($LoginId))echo $LoginId;?>'/><br> Enter Password<br><input type='password' name='Password1' value='<?php if(!empty($Password1))echo $Password1;?>'/><br> Confirm Password<br><input type='password' name='Password2' value='<?php if(!empty($Password2))echo $Password2;?>'/><br> Enter Name<br><input type='text' name='Name' value='<?php if(!empty($Name))echo $Name;?>'/><br> Enter Age<br><HEAD> <SCRIPT language=Javascript> function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } </SCRIPT> </HEAD> <INPUT onkeypress='return isNumberKey(event)' type='text' name='Age' value='<?php if(!empty($Age))echo $Age;?>'><br/> Enter Blood<br><input type='text' name='BloodGroup'value='<?php if(!empty($BloodGroup))echo $BloodGroup;?>'/><br> Enter Sex<br><input type='text' name='Sex'value='<?php if(!empty($Sex))echo $Sex;?>'/><br/> Enter Qualification<br><input type='text' name='Qualification' value='<?php if(!empty($Qualification))echo $Qualification;?>'/><br> Enter Email<br><input type='text' name='Email' value='<?php if(!empty($Email))echo $Email;?>'/><br> Enter Address<br><input type='text' name='Address' value='<?php if(!empty($Address))echo $Address;?>'/><br> About Yourself<br/><textarea rows='10' cols='22' name='AboutYourself' value='<?php if(!empty($AboutYourself))echo $AboutYourself;?>'></textarea><br/> <?php echo" <b>Select fields for which you want to register</b><br/>"; $dbc=mysqli_connect('localhost','root','','nog'); $query="select * from activity"; $result=mysqli_query($dbc,$query); while($row=mysqli_fetch_array($result)){ $Title=$row['Title']; $ActivityId=$row['ActivityId']; echo $Title; //echo $ActivityId; [b]echo "<input type='checkbox' name='checkbox[]' value=$ActivityId />"[/b];//value=$ActivityId tells ActivityId variable extracts with name="checkbox" echo "<br/>"; } echo "<input type='submit' value='Register' name='submit'/><br>"; echo "</form> </body> </html>";?> Quote Hi friends......... In above code I want to manadatory the checkboxes which works properly as well but when user not select any checkbox it should display "You have to register at least one activity." according to above code but user get an extra server error also "Notice: Undefined index: checkbox in C:\wamp\www\NGOProject\RegistrationAndActivity.php on line 16 You have to register at least one activity. " I don't want to display this extra server error "Notice: Undefined index: checkbox in C:\wamp\www\NGOProject\RegistrationAndActivity.php on line 16" to user............... please help me .......... Anyone??????????????? thanks in advance.................. Similar Tutorialshi, i have made a website where people resgister their details of them and products. they have to enter the following details in form Name of company name of the product company address email id password mobile number contact and brief details about their company
user can then login with email id and pwd. now after login ..user will get a page where he can upload the photos of products images and their price, so now my question is that when he finishes uploading (|by clicking on upload button) the product images and price text box ..then on final uploaded webspage it should show all other things which he registerd before (company name , mobile number etc) along with images and price...hence the main question that user does not need to enter mobile and address while uploading images and filling proce ..but on the final page it should show mobile and address along with price and images..as user is not going to enter mobile and address again and again as he will have multiple products to upload.
This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=350021.0 Hi, I have a set of checkboxes a bit like a checklist and I then want the items that aren't checked to displayed. On the first page, I have this code: <? while($row = mysql_fetch_array($result)) { ?> <form action="packed.php" method="post"> <div> <label><input type="checkbox" name="<? echo stripslashes($row['checklistitem']); ?>" value="yes"> <? echo stripslashes($row['checklistitem']); ?> </label> </div> This basically takes an array from a database. The info is then posted to the next page which hopefully will display the boxes which are 'unticked' or unchecked if you will. The code I have on the second page is: <?php $query_string = ""; if ($_POST) { $kv = array(); foreach ($_POST as $key => $value) { $kv[] = "$key"; } $query_string = join("<br />", $kv); } else { $query_string = $_SERVER['QUERY_STRING']; } echo $query_string; ?> At the moment, it returns the array items that were checked but I want the unchecked ones to be shown. Is that possible? Thanks very much! -Steve Hey all.. I have been messing around with some code with a form that has checkboxes on them, and the option of selecting more than one checkbox to submit to the database. However, I keep getting the error," Warning: Invalid argument supplied for foreach() in (mydirectory)". I have followed many tutorials and I don't see anything I am doing differently that they are, so I'm sure this is a simple fix, of something I am overlooking, or I am just horrible at this (new person). Here is the snippet of the HTML code for the checkboxes. Code: [Select] <label> <input type="checkbox" name="project_list[]" value="chat"/> Chat Project (age 18+ requirement)</label> <br /> <label> <input type="checkbox" name="project_list[]" value="forums"/> Forums Project (age 18+ requirement)</label> <br /> <label> <input type="checkbox" name="project_list[]" value="content"/> Content/Editorial Project (postcasts, blogging, etc.)</label> <br /> <label> <input type="checkbox" name="project_list[]" value="technology" /> Technology Project</label> <br /> <label> <input type="checkbox" name="project_list[]" value="marketing"/> Marketing, Promotions and Publicity</label> <br /> <label> <input type="checkbox" name="project_list[]" value="designartwork"/> Design and Artwork</label> Here is the PHP code that I am using to do this. Code: [Select] include 'db.php'; mysql_select_db('skylers_training'); if($_POST['submit']) { $project_lists = $_POST['project_list']; foreach($project_lists as $list); //This is the line the code is getting the error on. And the section of the INSERT MYSQL CODE for this part. Code: [Select] $reginsert = mysql_query("INSERT INTO ... // the rest of the code (that works fine) follows this. '$list' // This is the line that is supposed to send data from the checklists to the database. When I submit the form, in addition to the error, nothing is submitted to the database table for the list (everything else works fine). Any insight into this, would be appreciated. Thanks! Hey Everyone, I'm getting this error when I submit my contact form. Parse error: syntax error, unexpected $end in /home1/user/public_html/contact/process.php on line 22 I got this code from a video on youtube. http://www.youtube.com/watch?v=rdsz9Ie6h7I If I made a mistake or TYPO please let me know. Thanks! Here's my code: <?php $emailSubject = 'Contact Form Submission'; $sendto = 'info@mydomain.com'; $nameField = $_Post['name']; $emilField = $_Post['email']; $phoneField = $_Post['phone']; $SubjectField = $_Post['subject']; $messageField = $_Post['message']; $body = <<<EOD <br><hl><br>This Form was submitted from the Domain.com contact page.<br> Name: $name<br> E-Mail: $email<br> Phone: $phone<br> Subject: $subject<br> Message: $message<br> BOD; $headers = "FROM: $email\r\n"; $headers .="Content-Type: text/html\r\n"; $success = mail($sendto, $emailSubject, $body, $headers); ?> The html Form I'm using works successfully with this php code:
<?php //check if form was sent if($_POST){ $to = 's@hmail.com'; $subject = 'Form1'; $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $headers = $name; $message .= "\r\n\r\n" . $name; if( empty($_POST["some_place"]) or $_POST['some_place'] != "glory" ) { header("HTTP/1.0 403 Forbidden"); }else{ mail( $to, $subject, $message, $email, $headers ); } header('Location: https://.......com'); exit; } ?>
The problem is that when the email is received it shows the (from) email address to be my domain account user name @ the server name, like this: Any help or suggested remedy will be appreciated I am developing a CMS for my clients where the login to administrate their website is through my own website. This unified back-end allows me to develop the functionality and user experience without the issue of updating each site manually with the new files or running a complicated macro etc and then uploading them all individually too. I would also like to combine as much of the "client side" CMS code too, i.e. as many of the php files that are stored on the clients website as possible. All of the websites (and the backend website) are located on the same VPS, running PHP V5.3, allow_url_include is not available, I could have it turned on but this causes security issues if I understand correctly? I figure my main options a - Turn on allow_url_include and just include via IP/Domain. - Use a FTP system similar to the way Wordpress allows remote install of plugins and system updates. or - Include the files using a different /home/username/cmsincludes/ path? Is it possible to use another VPS account to include from? I have tested and it gives me a "failed to open stream" error. Example: Client xyz Website Website located: /home/xyz/public_html/ CMS Included: /home/mainsite/cms/ Client 123 Website Website located: /home/123/public_html/ CMS Included: /home/mainsite/cms/ Client xxx Website Website located: /home/xxx/public_html/ CMS Included: /home/mainsite/cms/ Hello, I need to execute a remote web page (distant server) every X seconds. How is it possible and is there any way to make it look exactly like a normal user request through a standard browser like Firefox, Chrome, etc. ? I've heard of cURL, but it seems that servers may block it, so there must be somehow a difference between a usual user request and a cURL execution. Thank you for any help ! :-) Matthew I want to fetch data from a table let's say table "activities". Uid | day | activity | time | remarks 1. Mon. Act1. 3pm. Good 2. Mon. Act1. 5pm. Bad 1. Tue. Act2. 12am. Bad 1. Tue. Act5. 1am. Bad 1. Thur. Act8. 9pm. Good 2. Wed. Act4. 7am. Good
Now assuming I want to fetch all the data that is related to user Id 1 and display them in another table (Uid 1). Which is 4 rows according to the table, how do I go about it using select query? Thanks!!! I tried something like this but it displays just one row <?php $uid = $_SESSION['login']; $sql2 = "SELECT * FROM Activities WHERE uid=? ORDER BY Uid LIMIT 6"; $stmt2 = $connection->prepare($sql2); $stmt2->bind_param('i', $Uid); $stmt2->execute(); $result2 = $stmt2->get_result(); $row2 = $result2->fetch_assoc(); //now am stuck here ?> now trying to display the fetch those data for only Uid 1 in these simple format...
<table style="width:100%"> <tr> <th>Day</th> <th>Activity</th> <th>Remarks</th> </tr> <tr> <td>Mon</td> <td>Act1</td> <td>Good</td> </tr> <tr> <td>Tue</td> <td>Act2</td> <td>Bad</td> </tr> <tr> <td>Tue</td> <td>Act5</td> <td>Bad</td> </tr> </table>
ok this is killing me!!!!! I have a form with serveral fields but I'm only going to show one field for now <?php include('/Connections/dbconnect.php'); ?> <?php if(isset($_POST['long'])){ $name = trim($_POST['fullname']); $insertq = ("INSERT INTO customer_details (`full_name`,) VALUES (`$name`) "); $insert = mysql_query($insertq) or die (mysql_error); $url = "/index.php"; header("Location: $url"); } ?> <form action="" method="POST" name="longform1" id="longform1" > <input name="fullname" type="text" id="fullname" size="25" maxlength="50" /> <input type="submit" name="long" id="long" value=" Submit " /> </form> in the data base I have a table called "customer_details" which has customerID, full_name simple stuff so far!!!!!!!!!!! the database conntect file has............... $hostname_superconnect = "localhost"; $database_superconnect = "connect"; $username_superconnect = "name"; $password_superconnect = "password"; $superconnect = mysql_pconnect($hostname_superconnect, $username_superconnect, $password_superconnect) or trigger_error(mysql_error(), mysql_select_db($database_superconnect); when I enter a name into the field the page comes back blank and says only.... mysql_error When I check the server error logs i get..... [Wed May 11 16:17:25 2011] [error] [client ] File does not exist: /home/sites/site.com/public_html/none [Wed May 11 16:17:38 2011] [error] [client ] PHP Warning: include(../Connections/dbconnect.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/sites/site.com/public_html/index.php on line 1, referer: http://www.site.com/index.php [Wed May 11 16:17:38 2011] [error] [client ] PHP Warning: include(../Connections/dbconnect.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /home/sites/site.com/public_html/index.php on line 1, referer: http://www.site.com/index.php [Wed May 11 16:17:38 2011] [error] [client ] PHP Warning: include() [<a href='function.include'>function.include</a>]: Failed opening '../Connections/dbconnect.php' for inclusion (include_path='.:/usr/share/pear5') in /home/sites/site.com/public_html/index.php on line 1, referer: http://www.site.com/index.php [Wed May 11 16:17:38 2011] [error] [client ] PHP Warning: mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: Access denied for user 'sit'@'localhost' (using password: NO) in /home/sites/site.com/public_html/index.php on line 14, referer: http://www.site.com/index.php [Wed May 11 16:17:38 2011] [error] [client ] PHP Warning: mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: A link to the server could not be established in /home/sites/site.com/public_html/index.php on line 14, referer: http://www.site.com/index.php Does anybody know whats wrong here. It must be a server error but thats just a beginners guess Hi all, I have an ajax comment system that is meant to be quite simple! This works fine on localhost, but when on my vps for some reason its throwing a 500 error. I have checked the logs but nothing is mentioned. I am wondering if anyone can throw some light on where to start? Chrome shows this: Request URL:http://www.buy2earn.co.uk/submit.php Request Method:POST Status Code:500 Internal Server Error Request Headers Accept:application/json, text/javascript, */* Content-Type:application/x-www-form-urlencoded Origin:http://www.buy2earn.co.uk Referer:http://www.buy2earn.co.uk/viewm.php?m_id=1 User-Agent:Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7 X-Requested-With:XMLHttpRequest Form Data name:admin merchant:1 body:gjgjkgj Response Headers Connection:close Content-Length:0 Content-Type:text/html; charset=UTF-8 Date:Tue, 23 Nov 2010 19:48:22 GMT Server:Apache/2.2.3 (CentOS) X-Powered-By:PHP/5.2.13 submit.php exists at the location shown hello when i put in my script i get a server error The website encountered an error while retrieving http://www.webiste.com/storeadmin/admin_login.php. It may be down for maintenance or configured incorrectly. Here are some suggestions: Reload this webpage later. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request. Code: [Select] <?php session_start(); if (isset($_SESSION["manager"])){ header("location:index.php"); exit(); } //check if their loged in ?> <?php if (isset($_POST["username"])&&isset($_POST["password"])){ $manager = preg_replace('#[^A-Za-z0-9]#i',",$_POST["username"]); $password = preg_replace('#[^A-Za-z0-9]#i',",$_POST["password"]); //connect to db include"../storescripts/connect.php"; $sql = mysql_query("SELECT id FROM admin WHERE username ='$manager' AND password='$password' LIMIT 1"); //make sure manager exsits $exsitCount = mysql_num_rows($sql);//counts the rows nums if($exsitCount == 1){ while($row = mysql_fetch_array($sql)){ $id= $row["id"]; } $_SESSION["id"]=$id; $_SESSION["manager"]=$manager; $_SESSION["password"]=$password; header("location:index.php"); exit(); }else{ echo 'That information is incorrect, try again <a href="index.php">Click here</a>'; exit(); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <div align="center" id="mainWrapper"> <?php include_once("../header.php");?> <div id="pagecontent"><br /> <div align="left" style="margin-left:24px;"> <h2>Please Log In To Manage The Store</h2> <form id="form1" name="form1" method="post" action="admin_login.php"> User Name:<br /> <input name="username" type="text" id="username" size="40"/> <br /><br /> Password:<br /> <input name="password" type="password" id="password" size="40"/> <br /> <br /> <br /> <label> <input type="submit" name="button" id="button" value="Login" /> </label> </form> <p> </p> </div> <br /> <br /> <br /> </div> <?php include_once("../footer.php");?> </div> </body> </html> Hi, I'm trying to display a user review system allowing user's to vote. This works fine, but I'm trying to user php to only display the rating system if the user is logged in and display alternate text if they are not. I am getting the following error: Parse error: syntax error, unexpected T_ELSE in XXXXXX on line 182 Here's the code: Code: [Select] <?php if ($_SESSION['username']){ $query = mysql_query("SELECT * FROM locations WHERE name = '$location'"); while($row = mysql_fetch_array($query)) { $rating = (int)$row[rating] ?> <div class="floatleft"> <div id="rating_<?php echo $row[id]; ?>"> <span class="star_1"><img src="fivestars/star_blank.png" alt="" <?php if($rating > 0) { echo"class='hover'"; } ?> /></span> <span class="star_2"><img src="fivestars/star_blank.png" alt="" <?php if($rating > 1.5) { echo"class='hover'"; } ?> /></span> <span class="star_3"><img src="fivestars/star_blank.png" alt="" <?php if($rating > 2.5) { echo"class='hover'"; } ?> /></span> <span class="star_4"><img src="fivestars/star_blank.png" alt="" <?php if($rating > 3.5) { echo"class='hover'"; } ?> /></span> <span class="star_5"><img src="fivestars/star_blank.png" alt="" <?php if($rating > 4.5) { echo"class='hover'"; } ?> /></span> </div> </div> <div class="star_rating"> (Rated <strong><?php echo $rating; ?></strong> Stars) </div> <div class="clearleft"> </div> } } <?php else { echo "Log in to review"; } ?> Thanks in advance for any help. I'm sure it's something trivial but I can't see it! Good Day PHP world,
I am encountering a problem in php code meant to allow the user to update their profile picture.
I am using jquery.min and jquery.js. The code below runs with no errors reported. The file has been successfully uploaded to upload path using this form.
upload.php
<form id="imageform" method="post" enctype="multipart/form-data" action='ajaximage.php'> <input type="file" name="photoimg" id="photoimg" class="stylesmall"/> </form>ajaximage.php $path = "uploads/"; $valid_formats = array("jpg", "png", "gif", "bmp","jpeg"); if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST") { $name = $_FILES['photoimg']['name']; $size = $_FILES['photoimg']['size']; if(strlen($name)) { list($txt, $ext) = explode(".", $name); if(in_array($ext,$valid_formats)) { if($size<(1024*1024)) // Image size max 1 MB { $actual_image_name = $name.".".$ext; $tmp = $_FILES['photoimg']['tmp_name']; if(move_uploaded_file($tmp, $path.$actual_image_name)) { $query = "UPDATE users SET profile_image='$actual_image_name' WHERE student_id='{$_SESSION['user_id']}'"; $result = mysqli_query($link_id, $query); echo "<img src='uploads/".$actual_image_name."' class='preview'>"; }The problem is the image being uploaded does not display on the Student_home.php <div id="about-img"> <img class="profile-photo" align="middle" src='uploads/".$actual_image_name."' /> </div>But the image uploaded will display when i write directly its filename example <div id="about-img"> <img class="profile-photo" align="middle" src="uploads/107.jpg" /> </div>My problem is i wanted to display the uploaded picture of the specific student on Student_Home.php Hi all I need some help with displaying user account details i am currently able to show only the email address and i would like to show the name school name and yeargroup heres my code for myaccount.php <?php require_once('Connections/isn_1.php'); ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = "1,2,3,4"; $MM_donotCheckaccess = "false"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && false) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "login.php?login=false"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) $MM_referrer .= "?" . $_SERVER['QUERY_STRING']; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <!DOCTYPE HTML> <html> <head> <title>My Account - <?php echo($_SESSION['MM_Username']); ?></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style type="text/css"> @import url("style.css"); </style> </head> <body class="about"> <!-- Start NavBar --> <div id="topnavbar"> <dl> <dt id="home"><a href="index.php">Home</a></dt> <dt id="about"><a href="about.php">About</a></dt> <dt id="account"><a href="myaccount.php">Account</a></dt> <dt id="login"><a href="login.php">Login</a></dt> </dl> <dl id="rightnavbar"> <dt id="ISN"><a href="index.php">ISN</a></dt> </dl> </div> <!-- End NavBar --> <div id="page-container"> <div id="header"> </div> <div id="sidebar-a"></div> <div id="content"> <div class="padding"> <center> <table width="631" border="0"> <tr> <td colspan="2">Personal Details</td> </tr> <tr> <td width="229"> </td> <td width="648"></td> </tr> <tr> <td>Name</td> <td></td> </tr> <tr> <td>Email</td> <td><?php echo($_SESSION['MM_Username']); ?></td> </tr> <tr> <td>School Name</td> <td></td> </tr> <tr> <td>Year Group</td> <td></td> </tr> <tr> <td>DOB</td> <td></td> </tr> <tr> <td> </td> <td><a href="updateprofile.php">Modify my details</a></td> </tr> </table> <a href="logout.php">Logout?</a> </center> </div> </div> <div id="footer"> <div id="altnav"> <a href="index.php">Home</a> - <a href="login.php">Login</a> - <a href="register.php">Register</a> - <a href="about.php">About</a> - <a href="terms.php">Terms & Conditions</a> </div> <div id="copyright">© 2011 InterSchoolsNetwork, All Rights Reserved - A <a href="http://jordansmithsolutions.co.uk">Jordan Smith Solutions</a> & <a href="http://www.joecocorp.webs.com/">JoeCo Corp Production</a><br /> </div> </div> </div> </body> </html> <?php mysql_free_result($rsUpdateUser); ?> If you need any other code to help answer it for me then let me no please after the user has logged in, I would like to display their details by barcode id Login.php <?php $host=""; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); session_start(); // username and password sent from form $barcodeID=$_POST['barcode']; // To protect MySQL injection (more detail about MySQL injection) $barcodeID = stripslashes($barcodeID); $barcodeID = mysql_real_escape_string($barcodeID); $sql="SELECT * FROM $tbl_name WHERE BarcodeID='$barcodeID'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count > 0){ $data = mysql_fetch_array ($result); $_SESSION["user_id"] = $data["BarcodeID"]; $_SESSION["user_firstname"] = $data["Firstname"]; $_SESSION["user_surname"] = $data["Surname"]; $_SESSION["user_jobrole"] = $data["JobRole"]; $_SESSION["user_manager"] = $data["Manager"]; $_SESSION["user_priority"] = $data["Priority"]; $_SESSION["user_datejoined"] = $data["DateJoined"]; $_SESSION["user_times_loggged_in"] = $data["TimesLoggedOn"]; if ($_SESSION["user_priority"] == '1') { header("Location: AdminSection.php"); } else { header("Location:LoggedIn.php"); } if ($_SESSION["user_times_loggged_in"] == '0') { header("Location:UsingTheSystem.html"); } } ?> LoggedIn.php I keep getting the error undefined index "barcode"? <?php $barcodeID = $_POST["barcode"]; include 'dbcon.php'; $sql = "SELECT Firstname, Surname, JobRole, Manager" . " FROM users" . " WHERE BarcodeID = .'$barcodeID'" ; $rows = mysql_query($sql); echo $rows; ?> Any help will be greatly appreciated Thanks Code: [Select] <html> <title>Micro Elite Brigade - Registration</title><LINK REL="SHORTCUT ICON" HREF="images/favicon.png"><?php require_once('upper.php'); require_once('database.php'); echo $error_msg=''; if(isset($_POST['submit'])) { $LoginId=mysqli_real_escape_string($dbc,trim($_POST['LoginId'])); $Password1=mysqli_real_escape_string($dbc,trim($_POST['Password1'])); $Password2=mysqli_real_escape_string($dbc,trim($_POST['Password2'])); $Name=mysqli_real_escape_string($dbc,trim($_POST['Name'])); $Age=mysqli_real_escape_string($dbc,trim($_POST['Age'])); $BloodGroup=mysqli_real_escape_string($dbc,trim($_POST['BloodGroup'])); /*if(!isset($_POST['Sex'])) { echo 'Please enter Sex<br>'; }*/ //else{ $Sex= mysqli_real_escape_string($dbc,trim($_POST['Sex'])); //} $Qualification=mysqli_real_escape_string($dbc,trim($_POST['Qualification'])); $ContactNumber=mysqli_real_escape_string($dbc,trim($_POST['ContactNumber'])); $Email=mysqli_real_escape_string($dbc,trim($_POST['Email'])); $Address=mysqli_real_escape_string($dbc,trim($_POST['Address'])); $AboutYourself=mysqli_real_escape_string($dbc,trim($_POST['AboutYourself'])); //$countCheck=count($_POST['checkbox']); //echo $countCheck; //$checkbox=$_POST['checkbox']; //$countCheck=count($checkbox); if(empty($LoginId)){echo 'Please enter Login Id';} elseif(empty($Password1)){echo 'Please enter Password';} elseif(empty($Password2)){echo 'Please confirm Password';} elseif($Password1!==$Password2){echo 'Password didn\'t match';} elseif(empty($Name)){echo 'Please enter Name';} elseif(empty($Age)){echo 'Please enter Age';} elseif(!isset($_POST['Sex'])){echo 'Please enter Sex';} elseif(empty($Qualification)){echo 'Please enter Qualification';} elseif(empty($ContactNumber)){echo 'Please enter Contact Number';} elseif(empty($Email)){echo 'Please enter Email';} elseif(empty($Address)){echo 'Please enter Address';} elseif(empty($AboutYourself)){echo 'Please enter About Yourself';} elseif(!isset($_POST['checkbox'])){ echo 'You have to register at least one activity.';} elseif(!isset($_POST['TermsAndConditions'])){ echo 'You have to agree all Terms and Conditions of Elite Brigade.';} else { require_once('database.php'); $query="select * from registration where LoginId='$LoginId'"; $result=mysqli_query($dbc,$query); if(mysqli_num_rows($result)==0) { $checkbox=$_POST['checkbox']; $countCheck=count($_POST['checkbox']); $reg_id=' '; for($i=0;$i<$countCheck;$i++) { $reg_id=$reg_id.$checkbox[$i].','; $query="insert into activity_participation (LoginId,Title,Date) values ('$LoginId','$checkbox[$i]',CURDATE())"; $result=mysqli_query($dbc,$query) or die("Not Connected"); } $query="insert into registration (LoginId,Password,Name,Age,BloodGroup,Sex,Qualification,ContactNumber,Email,Address,AboutYourself,Activity)values ('$LoginId',SHA('$Password1'),'$Name','$Age','$BloodGroup','$Sex','$Qualification','$ContactNumber','$Email','$Address','$AboutYourself',',$reg_id')"; $result=mysqli_query($dbc,$query) or die("Not Connect"); echo ' Dear '.$Name.'.<br>Your request has been mailed to admin.<br>Your account is waiting for approval<br>'; $from= 'Elite Brigade'; $to='ankitp@rsquareonline.com'; $subject='New User Registration'; $message="Dear admin,\n\nA new user request for registration. Please check it out.\n\nRegards\nMicro"; mail($to,$subject,$message,'From:'.$from); //header('Location: index.php'); // header('Location: Registration.php'); } else { echo 'Dear '.$Name. ', <br> An account already exist with login-id<b> '.$LoginId.'</b> <br>Please try another login-id'; }} } ?> <html> <head> <link rel="stylesheet" type="text/css" href="css/style.css" /> <script type="text/javascript"> function lengthRestriction(elem, min, max){ var uInput = elem.value; if(uInput.length >= min && uInput.length <= max){ return true; }else{ alert("Please enter between " +min+ " and " +max+ " characters"); elem.value=""; return false; } } function emailValidator(elem, helperMsg){ var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/; if(elem.value.match(emailExp)){ return true; }else{ alert(helperMsg); elem.value=""; return false; } } </script> </head> <body> <?php echo $error_msg; ?> <form action='<?php echo $_SERVER['PHP_SELF'];?>' id="commentForm" method='post'> <div class="registration_and_activity"> <table border="0" cellspacing="0" cellpadding="0" width="380"> <tr><td colspan="2"> <br/><h3>New User?</h3></td></tr> <tr><td width="120"> <em>*</em>Enter Login id</td><td width="150"><input type='text' name='LoginId' id='LoginId' value='<?php if(!empty($LoginId))echo $LoginId;?>' onblur="lengthRestriction(document.getElementById('LoginId'), 6, 20)")/></td></tr> <tr><td> <em>*</em>Enter Password</td> <td><head> <SCRIPT language=Javascript> function capLock(e){ kc = e.keyCode?e.keyCode:e.which; sk = e.shiftKey?e.shiftKey:((kc == 16)?true:false); if(((kc >= 65 && kc <= 90) && !sk)||((kc >= 97 && kc <= 122) && sk)) { if(document.getElementById('Password1').value=='') alert("Caps Lock is On"); } else document.getElementById('divMayus').style.visibility = 'hidden'; } </SCRIPT> </HEAD> <input onkeypress='return capLock(event)' type='password' name='Password1' id="Password1" value='<?php if(!empty($Password1))echo $Password1;?>' onblur="lengthRestriction(document.getElementById('Password1'), 4, 50)")/></td></tr> <tr><td> <em>*</em>Confirm Password</td><td><input type='password' name='Password2' value='<?php if(!empty($Password2))echo $Password2;?>' /></td></tr> <tr><td width="120"> <em>*</em>Enter Name</td> <td><input type='text' name='Name' Id="Name" value='<?php if(!empty($Name))echo $Name;?>' onblur="lengthRestriction(document.getElementById('Name'), 2, 30)")/></td></tr> <tr><td> <em>*</em>Enter Age</td><HEAD> <SCRIPT language=Javascript> function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } </SCRIPT> </HEAD> <td><INPUT onkeypress='return isNumberKey(event)' type='text' name='Age' value='<?php if(!empty($Age))echo $Age;?>'/></td></tr> <tr><td> <em>*</em>Enter Blood</td><td><input type='text' name='BloodGroup' value='<?php if(!empty($BloodGroup))echo $BloodGroup;?>' id="BloodGroup" onblur="lengthRestriction(document.getElementById('BloodGroup'), 1, 3)") /></td></tr> <tr><td> <em>*</em>Enter Sex</td><td><input type='radio' name='Sex' style='width:16px; border:0;' value='Male'<?php if(isset($_POST['Sex'])) { echo "checked='checked'";} ?> />Male <input type='radio' name='Sex' style='width:16px; border:0;' value='Female' <?php if(isset($_POST['Sex'])) { echo "checked='checked'";} ?> />Female</td></tr> <tr><td> <em>*</em>Enter Qualification</td><td><input type='text' name='Qualification' value='<?php if(!empty($Qualification))echo $Qualification;?>' id="Qualification" onblur="lengthRestriction(document.getElementById('Qualification'), 3, 60)"/></td></tr> <tr><td> <em>*</em>Contact Number </td><td><input onkeypress='return isNumberKey(event)'type='text' name='ContactNumber' value='<?php if(!empty($ContactNumber))echo $ContactNumber;?>' /></td></tr> <tr><td> <em>*</em>Enter Email</td><td><input type='text' name='Email'class="email" value='<?php if(!empty($Email))echo $Email;?>' id="emailer" onblur="emailValidator(document.getElementById('emailer'), 'Not a Valid Email')"/></td></tr> <tr><td> <em>*</em>Enter Address</td><td><input type='text' name='Address' value='<?php if(!empty($Address))echo $Address;?>' id="Address" onblur="lengthRestriction(document.getElementById('Address'), 2, 100)")/></td></tr> <tr ><td > <em>*</em>About Yourself </td></tr> <tr><td colspan="2"><textarea rows='10' cols='40' name='AboutYourself' id="AboutYourself" onblur="lengthRestriction(document.getElementById('AboutYourself'), 5, 500)") /><?php if(!empty($Address))echo $Address;?></textarea></td></tr> <tr><td> <?php echo" <tr><td colspan='2'><em>*</em><b>Select fields for which you want to register</b></td></tr>"; require_once('database.php'); $query="select * from activity"; $result=mysqli_query($dbc,$query); while($row=mysqli_fetch_array($result)){ $Title=$row['Title']; $ActivityId=$row['ActivityId']; echo "<tr><td>$Title</td>"; echo "<td><input type='checkbox' name='checkbox[]' value='$Title' style='width:14px; text-align:right;'/></td></tr>";//value=$ActivityId tells ActivityId variable extracts with name="checkbox" echo "<br/>"; } echo " <tr> <table border='0' cellspacing='0' cellpadding='0' width='400' style='margin:10px 0 0 0;'> <td align='left' valign='top' scope='col' width='80'><em>*</em><input type='checkbox' name='TermsAndConditions' style='width:14px; text-align:right;'/></td> <td align='left' valign='top' scope='col'> I agree all <a href='TermsAndConditions.php'>Terms and conditions </a>of Elite Brigade.</td> </table> </tr>"; echo "<tr><td colspan='2' align='center'><input type='submit' value='Register' name='submit' style='background:url(./images/button_img2.png) no-repeat 10px 0px; width:100px; padding:3px 0 10px 0; color:#FEFBC4; border:0; margin:15px 0 5px 100px; '/></td></tr><br>"; echo " </td></tr></table> </div> </form> </body> </html>"; require_once('lower.php'); ?>Hi friends.......... I have two problems with this page....... 1--> When user not select radio button it should displays "Please enter Sex" but on submit it displays an error "Undefined index: Sex in C:\wamp\www\EliteBrigadeserver\RegistrationAndActivity.php on line 19 Please enter Sex." I want to remove this notice........ 2--> If user not fill any field and press submit then if user once selected his sex, it should remain selected. Help me please............ Anyone????????? thanks in advance................... Dear everyone, I am reasonably new to php, so there is a chance that what I am asking for may exceed my grasp. Nevertheless I'd like to try: Is it possible to let the user choose (by using a drop down listbox for instance) which table from a database to display on a page? And/or which database to display on a page? Background information: I'm working on a website for my chess club. I've already got a working page (html,css) with a table of the standings (mysql, php) of the latest round (with position number, name, points, wins, losses, etc). By clicking on the column header, it sorts the respective column. What I'd finally like to do is let the user choose to display a different round (table), or even a different season (database). I could make a seperate page for each round, but I'd like to know if there's a more elegant way to do this by using only one page and one or more databases. Thanks in advance for any tips and best wishes from The Netherlands, Wouter. So I have some php code within an html page (using Apache v2.2, PHP v5.2) that uses MySQLI to connect to a database and fetch some rows from a database. Everything works fine so long as I limit the number of rows fetched, if I try to fetch all the rows, I get a 500 Internal Server Error in my browser. I am using GoDaddy Hosting -- has anyone encountered this problem/know what the hell is going on? Hi. I'm trying to build a sort of blog where users have to register to post questions/comments. My problem is with the registration part. Here is part of the code: Code: [Select] <form name="registration" method="post" action="registration.php"> <tr><td align="left">Nume</td> <td align="right"><input type="text" name="name" onKeyUp="validare()"></td></tr> <tr><td align="left">Email</td> <td align="right"><input type="text" name="email" onKeyUp="validare()"></td></tr> <tr><td align="left">Username</td> <td align="right"><input type="text" name="username" onKeyUp="validare()"></td></tr> <tr><td align="left">Parola</td> <td align="right"><input type="password" name="password" onKeyUp="validare()"></td></tr> <tr><td align="left">Confirmare parola</td> <td align="right"><input type="password" name="pass_conf" onKeyUp="validare()"></td></tr> <tr><td align="left">Anti-spam</td> <td><script type="text/javascript">DrawBotBoot()</script></td></tr> <tr><td></td><td><input type="submit" name="register" value="Inregistreaza-te" disabled="true"></td></tr> </form>... </html> Code: [Select] <?php $host="mysql3.***************"; $username="a7129718_root"; $password="hello2"; $db_name="a7129718_site"; $tbl_name="members"; // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT MAX(id) AS Maxa_id FROM $tbl_name"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); if ($rows) { $Max_id = $rows['Maxa_id']+1;} else { $Max_id = 1;} $name=$_POST['name']; $email=$_POST['email']; $user=$_POST['username']; $pass=$_POST['password']; $sql2="INSERT INTO $tbl_name(id, name, email, username, password)VALUES('$Max_id', '$name', '$email', '$user', '$pass')"; $result2=mysql_query($sql2); if($result2){ header("location:login.html");} else{ echo "cannot insert into table";}} ?> The problem is: there is no error message. The server just redirects me to their error page, which doesn't contain any error code, just some ads. Can you tell me what the problem might be? Thank you in advance. Bye." |