Jump to content

thelee

Members
  • Posts

    60
  • Joined

  • Last visited

Everything posted by thelee

  1. i want create a form to make a order.but for the name form,i want to it fill automatically based on session login. can someone help me ? here is some detail that i can provide for the order form <?php session_start(); if(isset($_SESSION['MM_Username'])) { echo "Welcome ".$_SESSION['MM_Username'].""; } else { echo "why you dont register?"; } ?> <style type="text/css"> <!-- .style1 {color: #FFFF00} .style4 {color: #00FFFF} .style8 {color: #00FF00} .style9 {color: #FFFFFF} .style10 { font-size: 18px; color: #FFFFFF; } body { background-image: url(wallpaper%20system.jpg); } body {background-attachment:fixed} body {background-repeat:no-repeat} --> </style> </head> <body> <form name="form1" method="post" action="order_product_process.php"> <p align="center" class="style10"> </p> <p align="center" class="style10"> </p> <p align="center" class="style10"> </p> <p align="center" class="style10"> </p> <p align="center" class="style10">Order Form:</p> <div align="center"> <table width="249" border="1" bgcolor="#000000"> <tr> <td width="54"><span class="style1">Name</span></td> <td width="179"><input name="name" type="text" id="name" maxlength="30"></td> </tr> <tr> <td><span class="style4">Address</span></td> <td><textarea name="address" id="address"></textarea></td> </tr> <tr> <td><span class="style1">Phone</span></td> <td><input name="phone" type="text" id="phone" maxlength="30"></td> </tr> <tr> <td><span class="style9">IC Number </span></td> <td><input name="ic" type="text" id="ic" maxlength="30"></td> </tr> <tr> <td><span class="style8">Product Name </span></td> <td><input name="product_name" type="text" id="product_name" maxlength="30"></td> </tr> <tr> <td><span class="style1">Quantity</span></td> <td> <input name="quantity" type="text" id="quantity" maxlength="30"></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Order"> <input name="Reset" type="reset" id="Reset" value="Reset"></td> </tr> </table> </div> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </form> </body> </html> here is the order databse structure CREATE TABLE `order` ( `order_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(30) NOT NULL DEFAULT '', `address` varchar(30) NOT NULL DEFAULT '', `phone` varchar(30) NOT NULL DEFAULT '', `ic` varchar(30) NOT NULL DEFAULT '', `product_name` varchar(30) NOT NULL DEFAULT '', `quantity` int(30) NOT NULL DEFAULT '0', PRIMARY KEY (`order_id`) ) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=latin1
  2. how i can change the value of the bar chart ? i want the "x" value is month and "y" value is registered user and it is automatically update everytime a person register. can someone help me ?
  3. hello. i am still new in using php coding.i hope anybody can explain me detail how to solve my problem.i want to generate a bar graph. the value is automatically update from my total of registered user in a month.after do some research i have found a code how to build a bar graph.here is it <? # ------- The graph values in the form of associative array $values=array( "Jan" => 110, "Feb" => 130, "Mar" => 215, "Apr" => 81, "May" => 310, "Jun" => 110, "Jul" => 190, "Aug" => 175, "Sep" => 390, "Oct" => 286, "Nov" => 150, "Dec" => 196 ); $img_width=450; $img_height=300; $margins=20; # ---- Find the size of graph by substracting the size of borders $graph_width=$img_width - $margins * 2; $graph_height=$img_height - $margins * 2; $img=imagecreate($img_width,$img_height); $bar_width=20; $total_bars=count($values); $gap= ($graph_width- $total_bars * $bar_width ) / ($total_bars +1); # ------- Define Colors ---------------- $bar_color=imagecolorallocate($img,0,64,128); $background_color=imagecolorallocate($img,240,240,255); $border_color=imagecolorallocate($img,200,200,200); $line_color=imagecolorallocate($img,220,220,220); # ------ Create the border around the graph ------ imagefilledrectangle($img,1,1,$img_width-2,$img_height-2,$border_color); imagefilledrectangle($img,$margins,$margins,$img_width-1-$margins,$img_height-1-$margins,$background_color); # ------- Max value is required to adjust the scale ------- $max_value=max($values); $ratio= $graph_height/$max_value; # -------- Create scale and draw horizontal lines -------- $horizontal_lines=20; $horizontal_gap=$graph_height/$horizontal_lines; for($i=1;$i<=$horizontal_lines;$i++){ $y=$img_height - $margins - $horizontal_gap * $i ; imageline($img,$margins,$y,$img_width-$margins,$y,$line_color); $v=intval($horizontal_gap * $i /$ratio); imagestring($img,0,5,$y-5,$v,$bar_color); } # ----------- Draw the bars here ------ for($i=0;$i< $total_bars; $i++){ # ------ Extract key and value pair from the current pointer position list($key,$value)=each($values); $x1= $margins + $gap + $i * ($gap+$bar_width) ; $x2= $x1 + $bar_width; $y1=$margins +$graph_height- intval($value * $ratio) ; $y2=$img_height-$margins; imagestring($img,0,$x1+3,$y1-10,$value,$bar_color); imagestring($img,0,$x1+3,$img_height-15,$key,$bar_color); imagefilledrectangle($img,$x1,$y1,$x2,$y2,$bar_color); } header("Content-type:image/png"); imagepng($img); ?> and from the code i need to change which part so i can generate the value as like i want ? can someone help me.here is the detail of registered user CREATE TABLE `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL DEFAULT '', `address` varchar(100) NOT NULL DEFAULT '', `day` int(10) NOT NULL, `month` varchar(15) NOT NULL, `years` int(10) NOT NULL, `number` varchar(15) NOT NULL, `gender` varchar(100) NOT NULL, `email` varchar(100) NOT NULL, `password` varchar(100) NOT NULL DEFAULT '', `time` time NOT NULL, `date` date NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=114 DEFAULT CHARSET=latin1 <?php $user = $fullname = $address = $day = $month =$years =$number = $gender = $email = $password = $repeatpassword = $time = $date =""; if(isset($_POST['fullname'])) //check for existance <- ni check isset utk 1 form je dah ckp. isset tu yg biasa guna utk cek variable kosong ke x { //form data $fullname= strip_tags($_POST['fullname']); $address= strip_tags($_POST['address']); $day=strip_tags($_POST['day']); $month=strip_tags($_POST['month']); $years=strip_tags($_POST['years']); $number=strip_tags($_POST['number']); $gender=strip_tags($_POST['gender']); $email= strip_tags($_POST['email']); $password= strip_tags($_POST['password']); $repeatpassword= strip_tags($_POST['repeatpassword']); $time = date("H:i",time()); $date = date('y/m/d', time()); ///<<<< date for registered user // echo $fullname; //encrypt password //$repeatpassword=md5($repeatpassword); ni tak perlu sebab yg kau nak simpan dalam database password je so aku dah 'comment' kan. (boleh padam bila2) if($password==$repeatpassword) { //check char length of username and fullname if (strlen($email)>25||strlen($fullname)>25){ echo "email or fullname is too long!"; } else { //check password length if (strlen($password)>25||strlen($password)<6){ echo "your password must be between 6 to 25 characters"; } else { //register the user! //encrypt password $password=md5($password); //Open database $connect = mysql_connect("localhost","root",""); mysql_select_db("phplogin"); //select database $queryreg = mysql_query(" INSERT INTO users VALUES ('','$fullname','$address','$day','$month','$years','$number','$gender','$email','$password','$time','$date') "); echo("You have been registered! <a href='index.php'>Return to login page</a>"); } } } else { echo "Your password do not match!"; } } ?>
  4. this one ? CREATE TABLE `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL DEFAULT '', `address` varchar(100) NOT NULL DEFAULT '', `day` int(10) NOT NULL, `month` varchar(15) NOT NULL, `years` int(10) NOT NULL, `number` varchar(15) NOT NULL, `gender` varchar(100) NOT NULL, `email` varchar(100) NOT NULL, `password` varchar(100) NOT NULL DEFAULT '', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=97 DEFAULT CHARSET=latin1
  5. can u give me any example ? sorry.im really newbie.
  6. <?php $user = $fullname = $address = $day = $month =$years =$number = $gender = $email = $password = $repeatpassword =""; if(isset($_POST['fullname'])) //check for existance <- ni check isset utk 1 form je dah ckp. isset tu yg biasa guna utk cek variable kosong ke x { //form data $fullname= strip_tags($_POST['fullname']); $address= strip_tags($_POST['address']); $day=strip_tags($_POST['day']); $month=strip_tags($_POST['month']); $years=strip_tags($_POST['years']); $number=strip_tags($_POST['number']); $gender=strip_tags($_POST['gender']); $email= strip_tags($_POST['email']); $password= strip_tags($_POST['password']); $repeatpassword= strip_tags($_POST['repeatpassword']); // echo $fullname; //encrypt password //$repeatpassword=md5($repeatpassword); ni tak perlu sebab yg kau nak simpan dalam database password je so aku dah 'comment' kan. (boleh padam bila2) if($password==$repeatpassword) { //check char length of username and fullname if (strlen($email)>25||strlen($fullname)>25){ echo "email or fullname is too long!"; } else { //check password length if (strlen($password)>25||strlen($password)<6){ echo "your password must be between 6 to 25 characters"; } else { //register the user! //encrypt password $password=md5($password); //Open database $connect = mysql_connect("localhost","root",""); mysql_select_db("phplogin"); //select database $queryreg = mysql_query(" INSERT INTO users VALUES ('','$fullname','$address','$day','$month','$years','$number','$gender','$email','$password') "); echo("You have been registered! <a href='index.php'>Return to login page</a>"); } } } else { echo "Your password do not match!"; } } ?> <html> <style type="text/css"> <!-- .style1 {color: #FFFFFF} body,td,th { font-family: Gisha; font-size: 24px; color: #FFFFFF; } body { background-image: url(); } .style2 { color: #FFFFFF; font-size: 24px; font-weight: bold; } --> </style> </span> <p align="center" class="style2 style9 style10">Registration Form</p> <div align="center"></div> <table width="486" height="495" border="1" align="center" bordercolor="#000000" bgcolor="#000000"> <tr> <td class="style11"> </td> </tr> <tr> <td width="476" class="style11"><form action ='registertest.php' method ='POST'> <p> <table width="498" border="1"> <tr> <td width="75">Name</td> <td width="407"><input name="fullname" type="text" id="fullname" value="<?php echo $fullname?>"></td> </tr> <tr> <td>Address</td> <td><textarea name="address" id="address"></textarea></td> </tr> <tr> <td>Date Of Birth</td> <td>Day <select name="day" size="1" id="day"> <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> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> Month <select name="month" size="1" id="month"> <option value="January">January</option> <option value="February">February</option> <option value="Mac">Mac</option> <option value="April">April</option> <option value="May">May</option> <option value="Jun">Jun</option> <option value="Julai">Julai</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="Disember">Disember</option> </select> <span class="style15">Year</span> <select name="years" id="years"> <option value="2012">2012</option> <option value="2011">2011</option> <option value="2010">2010</option> </select> </td> </tr> <tr> <td>Contact Number </td> <td><input name="number" type="text" id="number"></td> </tr> <tr> <td>Gender</td> <td><p> <label> <input type="radio" name="gender" value="Male"> Male</label> <br> <label> <input type="radio" name="gender" value="Female"> Female</label> <br> </p></td> </tr> <tr> <td>Email </td> <td><input name="email" type="text" id="email" value="<?php echo $email?>"> </td> </tr> <tr> <td>Choose Password </td> <td><input name="password" type="password" id="password"></td> </tr> <tr> <td>Confirm Password </td> <td><input name="repeatpassword" type="password" id="repeatpassword"> </td> </tr> </table> <p> <input type="submit" name="submit" value="Register"> <p> </form> <p> </p> <p> </p></td> </tr> </table> <p> </p> <p align="center" class="style16 style23 style2 style11"> //the day month and years is for the user date of birth.i dont know how to joined them together.so i just cr8 3 table.but its ok
  7. so i must create a new table for date in my database ? then put that code in register.php ?
  8. im really noob in php.i have a final year project and my lecturer ask me to build a nice system.so i have create a page for admin and i want to put a page where admin can see how much people register for that day or month.i dont mind whether it is day or month as long as it can show the record. and it will be nice if i can show the record in graph.can someone help me ?
  9. case solved ! thanks to social cloud ! love u muah
  10. hello.im creating a website.i want to show the user name after they logged in and for those who dont register i want to leave any msg. when the user login it will show welcome "the user name" but when the user dont log in,it will be a error, can someone help me. here is the code <?php session_start(); echo "Welcome ".$_SESSION['MM_Username']; else (isset($_SESSION['MM_Username'])) { echo "why you dont register?"; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.