Search the Community
Showing results for tags 'php html'.
-
In the code below I can get the total of the column into the field in a table,but how would I go about this if I wanted to get the total into a text box(html). I tried placing the $total variable into the value attribute of the text box but this didn't work.Any suggestions much appreciated:) $total = 0; // initialise total while($record = mysql_fetch_array($myData)){ echo "<tr>"; echo "<td>" . $record['id'] . "</td>"; echo "<td>" . $record['author'] . "</td>"; echo "<td>" . $record['title'] . "</td>"; echo "<td>" . $record['publisher'] . "</td>"; echo "<td>" . $record['year'] . "</td>"; echo "<td>" . $record['genre'] . "</td>"; echo "<td>" . $record['sold'] . "</td>"; echo "<tr />"; $total += $record['sold']; // accumulate total } echo "<tr><td colspan='6'>Total:</td><td>$total</td></tr>"; // output total echo "</table>"; Kind regards Lind
-
Hello.. I'm learning php and after seeing tutorials, made my first code to login. I need your help to find out if what I did is right, what needs to be improved (or even if everything is wrong) .. very grateful for your help / opinion . Thank you //This is my login page <?php session_start(); ?> <!DOCTYPE html> <html> <head> <title>Rede Social</title> <link rel="stylesheet" type="text/css" href="home.css"> </head> <body> <?php if(isset($_SESSION["tentarLogin"])){ unset($_SESSION["tentarLogin"]); } else{ $_SESSION["msg"]=""; $_SESSION["user"]=""; } ?> <h1 id="welcome">WELCOME!</h1> <form method="post" action="login.php" method="POST"> <div class="login" id="login"> <?php echo '<p id="welcome1">'.$_SESSION["msg"].'</p><br>' ;?> <input type = "text" id = "user" name="user" class="login-data" placeholder = "Username" value=<?php echo $_SESSION["user"]?>><br> <input type = "password" id = "pass" name = "pass"class="login-data" placeholder = "Password" ><br> <div class="submit"> <input type="submit" class ="submitButton" id="loginButton" value="LOGIN"><br> <input type="button" class ="submitButton" id="registarButton" onclick="location.href='/Rede%20Social/registar/registar.php'" value="REGISTAR"> </div> </div> </form> </body> </html> //This is my login form <?php session_start(); $user = $_POST["user"]; $pass = $_POST["pass"]; $_SESSION["tentarLogin"] = "true"; if(strcmp($user,"roger")==0){ if(strcmp($pass,"abreu")==0){ header('Location: http://www.google.pt'); } else{ $_SESSION["user"]="roger"; $_SESSION["msg"]="*Password errada!"; header('location: /Rede%20Social/home/home.php'); } } else{ $_SESSION["msg"]="*Username inexistente!"; header('location: /Rede%20Social/home/home.php'); } ?> Hello.. I'm learning php and after seeing tutorials, made my first code to login. I need your help to find out if what I did is right, what needs to be improved (or even if everything is wrong) .. very grateful for your help / opinion . Thank you
-
i have a form for sending email with cc and bcc bud when try to send it.. it shows an error.. please see it here http://www.pstwist.com/send-cc-email/ 123.zip
-
In the code below, I am trying to produce a google-like page where the user can type keywords and pages of search results are displayed. The main difficulty I am encountering is that when the browser changes pages, it forgets everything about current data. Perhaps I should include the display of pages inside the HTML form ? How can I fix this code ? Here is the contents of my searchpage.php file : <?php $keywords=''; $display_search_results=''; if(isset($_POST['search_submitted'])) { $keywords=$_POST['keywords']; $search_results=array(); $totalNbrOfItems=20; for($k=1;$k<=$totalNbrOfItems;$k++) { $search_results[$k]='Your keywords '$keyowrds.' have been found in item number '.$k; } $nbrOfItemsParPage = 5; $nbrOfPages = ceil($totalNbrOfItems / $nbrOfItemsParPage); // Compute current page $current_page = (isset($_GET['page']))?intval($_GET['page']):1; $display_pages=($nbrOfPages<2)?'<p>Page : ':'<p>Pages : '; for ($i = 1 ; $i <= $nbrOfPages ; $i++) { if ($i == $current_page) //No link to the current page { $display_pages=$display_pages.$i.' '; } else { $display_pages=$display_pages.'<a href="searchpage.php?'. 'page='.$i.'">'. $i . '</a> '; } } $display_pages=$display_pages.'</p>'; $display_items=''; $start=$nbrOfItemsPerPage*($current_page-1); for($k=1;$k<=$nbrOfItemsParPage;$k++) { $display_items=$display_items.($search_results[$start+$k]).'<br>'; } $display_search_results=$display_pages.$display_items; } echo '<form method="post" action="searchpage.php">'. ' Type your keywords here : <br><br>'. '<textarea cols="65" rows="1" '. 'id="keywords_id" name="keywords">'.$keywords.'</textarea>'. '<input type="submit" name="search_submitted" id="search_submitted_id" value="Search" /> '. '</fieldset>'. '</form>'; echo $display_search_results; ?>
-
I need a button in php to change my background color every 5 presses with a random one, every five presses the color have to change once and need to stay for the next 5 presses. here is my code <head> <title>click 5 times</title> <?php $a=array(0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f"); $culoare="#"; for($i=1; $i<6;$i++) $culoare.=$a[rand(0,16)]; session_start(); $_SESSION['counter'] = isset($_SESSION['counter']) ? $_SESSION['counter'] : 0; if($_POST['sub']) { $_SESSION['counter']++; echo "<br/>"; echo $culoare; echo "<body bgcolor='<?phpecho $culoare;?>'></body>"; } ?> </head> <body > <form action='' method="post"> <input type="submit" name="sub" value="click" /> <input type="hidden" name="counter" value="<?php print $_POST['counter']; ?>" /> </form> </body>
-
Trying to create a page that displays a form thats already populated from previous page. Now im trying to add an additional element into the already populated form, a coupon code. When I do this i lose all services and half my website disappears. Notice: Undefined index: service in /home/ on Line 91 line 91 is how i generated my services from previous page. here is my code: http://pastebin.com/NEeqpgxT what i want to figure out currently is why my page is disappearing and why its losing services.
-
I need some help with a problem that's frazzling my gray matter. I'm rewriting my website with Apache, PHP, PEAR & MYSQL the old version was written with Microsoft technologies IIS, ASP, VB & ACCESS. The site serves about 2000 members of which about 600-700 are emailed weekly with various updates (no spam). The email works from HTML templates which have text inserted to personalise them for each member, they also contain embedded graphics as logos. Most of site has been completed and here is my problem, With the VB version I used an Access front end connected to the database and when I sent the emails (using windows CDO) as each mail was sent details of that mail Name; ID; email address etc., were displayed on a form with a progress meter indicating which mail of the total was currently being sent. I would like to display this information on the web page as each mail is sent from the script but cannot get this to work (don't even know if it's possible !!). I am using an Index.php script but am unable to get the HTML display page to show each individual mail (one at a time) as the script is running. Any help greatly appreciated.
-
Hello everyone! Im trying to add a simple login form... But I get this error: "Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent..." Here's the code Im using for the whole page. <html> <?php require_once('index.php'); ?> <head> <title>login page</title> </head> <body bgcolor="black" style="color:gray"> <h1 align="center" style="color:gray" >Welcome to this simple application</h1> <form action="index.php" method=get> <?php session_start(); if( $_SESSION["logging"]&& $_SESSION["logged"]) { print_secure_content(); } else { if(!$_SESSION["logging"]) { $_SESSION["logging"]=true; loginform(); } else if($_SESSION["logging"]) { $number_of_rows=checkpass(); if($number_of_rows==1) { $_SESSION[user]=$_GET[userlogin]; $_SESSION[logged]=true; print"<h1>you have loged in successfully</h1>"; print_secure_content(); } else{ print "wrong pawssword or username, please try again"; loginform(); } } } function loginform() { print "please enter your login information to proceed with our site"; print ("<table border='2'><tr><td>username</td><td><input type='text' name='userlogin' size'20'></td></tr><tr><td>password</td><td><input type='password' name='password' size'20'></td></tr></table>"); print "<input type='submit' >"; print "<h3><a href='registerform.php'>register now!</a></h3>"; } function checkpass() { $servername="localhost"; $username="username"; $db_pass = "dbpass"; $db_name = 'db_name'; $conn= mysql_connect($servername,$username,$db_pass)or die(mysql_error()); mysql_select_db($db_name,$conn); $sql="select * from users where name='$_GET[userlogin]' and password='$_GET[password]'"; $result=mysql_query($sql,$conn) or die(mysql_error()); return mysql_num_rows($result); } function print_secure_content() { print("<b><h1>hi mr.$_SESSION[user]</h1>"); print "<br><h2>only a logged in user can see this</h2><br><a href='logout.php'>Logout</a><br>"; } ?> </form> </body> </html> What is it Im doing wrong? On a furthernote How can I guard against sql injections? Thanks for your time and patience!
-
Hi. So I have an online form that's pretty extensive. I'm having no issues with dropdowns, radios, text fields and single checkboxes, but a have a large list of options (checkboxes) for clients to check: <input type="checkbox" name="i_have[]" value="value1" />value1<br /> <input type="checkbox" name="i_have[]" value="value2" />value2<br /> <input type="checkbox" name="i_have[]" value="value3" />value3<br /> <input type="checkbox" name="i_have[]" value="value4" />value4<br /> <input type="checkbox" name="i_have[]" value="value5" />value5<br /> <input type="checkbox" name="i_have[]" value="value6" />value6<br /> ...and so on As you can see, I want this to be an array. I want it emailed to me - everything else emails fine, but this is proving a real problem. PHP side, I have tried: print_r($_POST['i_have']); with: Present Issues & Prior Illnesses: $i_haveField As the responder. All this does is posts the checked options on the "thanks for signing" page after the client hits the SUBMIT button, but it doesn't send anything in the email. I have also tried: if (isset($_POST['i_have'])) { $i_haveField = $_POST['i_have']; } This is one step closer, printing "ARRAY" in the appropriate area in the email responder, with nothing printed on the "thanks for signing" page, but no checked options are included in the email. Where am I going wrong?! I know it's something simple, but as a PHP newbie, I just can't see it. Please could you offer assistance.