Jump to content

Search the Community

Showing results for tags 'php'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 925 results

  1. undefined index grade in line 108 <?php if (!isset($_SESSION)) { session_start(); } IF(isset($_SESSION['username'])) ECHO "WELL COME ".$_SESSION['username']."<BR>"; else IF(isset($_SESSION['Name'])) if(isset($_POST['button'])) { $correct=0; $wrong=0; $sum=0; $grade=''; $total_q=@$_POST['total']; for($i=1;$i<=$total_q;$i++) { $con = mysql_connect("localhost","root"); mysql_select_db("oes", $con); $sql = "SELECT * from question_page where question='".@$_POST['q'.$i]."' and Answer='".@$_POST['ans'.$i]."'";// where schedule.status='active' $result = mysql_query($sql,$con); $result1 = mysql_fetch_array($result); if(mysql_num_rows($result)) $correct++; $wrong=$_POST['total']-$correct; $sum=($correct*10)/$_POST['total']; //echo "question of page:".@$_POST['q'.$i]." <br>answer of user ".@$_POST['ans'.$i]."<br>"; //echo "question of db:".$result1['question']." <br>answer of db ".$result1['Answer']."<br><br>"; if($sum>=9 && $sum<=10) { $grade="A+"; } else if($sum>=8.5 && $sum<9) { $grade="A"; } else if($sum>=8 && $sum<8.5) { $grade="A-"; } else if($sum>=7.5 && $sum<8) { $grade="B+"; } else if($sum>=7 && $sum<7.5) { $grade="B"; } else if($sum>=6.5 && $sum<7) { $grade="B-"; } else if($sum>=6 && $sum<6.5) { $grade="C+"; } else if($sum>=5 && $sum<6) { $grade="C"; } else if($sum>=4.5 && $sum<5) { $grade="C-"; } else if($sum>=4 && $sum<4.5) { $grade="D"; } else if($sum>=3.5 && $sum<4) { $grade="Fx"; } else if($sum>=0 && $sum<3.5) { $grade="F"; } } echo "total number of question ".$_POST['total']."<br>"; echo "total number of correct answer".$correct."<br>"; echo "total number of wrong answer".$wrong."<br>"; echo "total number of Marks:".$sum."<br>"; echo "your grade is:".$grade."<br>"; } else { header('location:Exam.php'); } ?> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css"> <style type="text/css"> </style> <div id="right"> <?php $cnct=mysql_connect("localhost","root","")or die("not connected"); $qry=mysql_select_db("oes") or die("not connected"); $crsnm=mysql_query("select course_name from schedule where schedule_id='".$_GET['Id']."'"); $data=mysql_fetch_array($crsnm); $a=$_SESSION['ID']; $b=$_SESSION['Name']; $c=$_POST['total']; $g=$_POST['grade']; $con=mysql_connect("localhost","root","")or die("not connected"); $query=mysql_select_db("oes") or die("note selected"); $res="insert into result values('$a','$b','$correct','$wrong','$sum','$c', '$g' ,'yes','".$data['course_name']."')"; $sql=mysql_query($res) or die(mysql_error()); if(!$sql) { echo"not inserted ".mysql_error()."<br>"; } else { echo"inserted"."<br>"."<br>"; } ?> <?php $a=$_SESSION['ID']; $b=$_SESSION['Name']; $c=$_POST['total']; $d=$_POST['grade']; $con=mysql_connect("localhost","root","")or die("not connected"); $query=mysql_select_db("oes") or die("note selected"); $sql=mysql_query("insert into result values('$a','$b','$correct','$wrong','$sum','$c','$d')") or die(mysql_error()); if(!$sql) { echo"not inserted ".mysql_error()."<br>"; } else { echo"inserted"."<br>"."<br>"; } mysql_close($con); ?> <br/--> <div align="center"> </div> <td bgcolor="#c24122">&nbsp;</td> </tr> </table> </div> </div> and it calculate the result from exam.php which are below as follows: <?php if (!isset($_SESSION)) { session_start(); } IF(isset($_SESSION['username'])) ECHO "WELL COME ".$_SESSION['username']."<BR>"; else IF(isset($_SESSION['Name'])) //ECHO "WELL COME ".$_SESSION['Name']."<BR>"; //ECHO "YOUR ID IS ".$_SESSION['ID']."<BR>"; $var=$_SESSION['ID']; //echo$_SESSION['Name']; ?> <?php $sql=mysql_connect("localhost","root","")or die("not connected"); mysql_select_db("oes"); ?> <!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=iso-8859-1" /> <link href="style.css" rel="stylesheet" type="text/css" /> <title></title> <style type="text/css"> <!-- .style1 { color: #FFFFFF; font-weight: bold; } --> </style> </head> <body> <div id="container"> <?php include "Header.php"; ?> <div id="content"> <div id="left"> <rights> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <?php /* echo $_SESSION['co1']."<br>"; echo $_SESSION['co2']."<br>"; echo $_SESSION['co3']; */ $con=mysql_connect("localhost","root","")or die('not selected'); mysql_select_db("oes",$con)or die('not selected'); $sql="select * from schedule"; $query=mysql_query($sql); while($row = mysql_fetch_array($query)) { $sub= $coname=$row['course_name']; //echo $sub."<br>"; } $gu=$var; //echo $gu; mysql_close($con); $con=mysql_connect("localhost","root","")or die("not connected"); $query=mysql_select_db("oes",$con)or die("not selected"); $sql= "select Stud_ID from result where Stud_ID='".$gu."' AND status='yes'"; $result = mysql_query($sql); //$date= $row_Recordsetd['exam_date']; //if(!mysql_num_rows($result)) //if((!mysql_num_rows($result))) { ?> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $dateFormat = "d F Y -- g:i a"; $targetDate = time() + (1*60);//Change the 25 to however many minutes you want to countdown $actualDate = time(); $secondsDiff = $targetDate - $actualDate; $remainingDay = floor($secondsDiff/60/60/24); $remainingHour = floor(($secondsDiff-($remainingDay*60*60*24))/60/60); $remainingMinutes = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))/60); $remainingSeconds = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))-($remainingMinutes*60)); $actualDateDisplay = date($dateFormat,$actualDate); $targetDateDisplay = date($dateFormat,$targetDate); ?> <?php $con1 = mysql_connect("localhost","root"); mysql_select_db("oes", $con1); $Recordsetd = mysql_query("SELECT exam_time From schedule where schedule_id='".@$_GET['Id']."'") or die(mysql_error()); $row_Recordsetd = mysql_fetch_array($Recordsetd); //$ex_tih=$row_Recordsetd['exam_time'][strlen($row_Recordsetd['exam_time'])-8].$row_Recordsetd['exam_time'][strlen($row_Recordsetd['exam_time'])-7]; //$ex_tim=$row_Recordsetd['exam_time'][strlen($row_Recordsetd['exam_time'])-5].$row_Recordsetd['exam_time'][strlen($row_Recordsetd['exam_time'])-4]; $ex_tis=$row_Recordsetd['exam_time'][strlen($row_Recordsetd['exam_time'])-2].$row_Recordsetd['exam_time'][strlen($row_Recordsetd['exam_time'])-1]; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Quiz System</title> <script type="text/javascript"> var days = <?php echo $remainingDay; ?> var hours = <?php echo $ex_tih; ?> var minutes = <?php echo $ex_tim; ?> var seconds = <?php echo $ex_tis; ?> function setCountDown () { seconds--; if (seconds < 0){ minutes--; seconds = 60 } if (minutes < 0) { hours--; minutes = 59 } if (hours < 0) { days--; hours = 23 } document.getElementById("remain").innerHTML = days+" days, "+hours+" hours, "+minutes+" minutes, "+seconds+" seconds"; SD=window.setTimeout( "setCountDown()", 1000 ); if (minutes == '00' && seconds == '00') { //seconds = "00"; window.clearTimeout(SD); { //document.getElementById('file2').style.visibility = 'hidden'; window.location = "check.php"; //document.getElementById('OptionA').disabled = true; } //window.alert("Time is up. Press OK to continue."); // change timeout message as required //$('input').disabled = true; } } </script> </head> <body onload="setCountDown();"> <!--Start Time: <!?php echo $actualDateDisplay; ?><br /> End Time:<!?php echo $targetDateDisplay; ?><br /--> <h2><b> <div id="remain"><?php echo "$remainingDay days, $remainingHour hours, $remainingMinutes minutes, $remainingSeconds seconds";?></div></b></h2> <h1> <!?php echo $_SESSION['Name'];?></h1> <p> <form id="form2" name="form2" method="post" action="point.php?Id=<?php if(isset($_GET['Id']))echo $_GET['Id'];?>"> <!--input type="text" name="course" value="<!?php if(isset($_GET['Id']))echo $_GET['Id'];?--> <?php $SID=@$_GET['Id']; // Establish Connection with Database $con1 = mysql_connect("localhost","root"); // Select Database mysql_select_db("oes", $con1); //$query_Recordsetd = ; $Recordsetd = mysql_query("SELECT course_name From schedule where schedule_id='".@$_GET['Id']."'") or die(mysql_error()); $row_Recordsetd = mysql_fetch_array($Recordsetd); $con = mysql_connect("localhost","root"); mysql_select_db("oes", $con); $sql = "SELECT * from question_page where course_name='".$row_Recordsetd[0]."'";// where schedule.status='active' $result = mysql_query($sql,$con); $i=1; while($row = mysql_fetch_array($result)) { $Id=$row['exam_id']; $Question=$row['question']; $OptionA=$row['Option1']; $OptionB=$row['Option2']; $OptionC=$row['Option3']; $OptionD=$row['Option4']; //echo $Id; ?> </p> <?php if($Id=='mult') { echo' <td colspan="2"><table width="100%" height="64" border="0" cellpadding="0" cellspacing="0" bordercolor="#A6BF79" say true or fales> <tr> <td height="32" width="50%">('.$i.')<input type="text" style="width:1000%;background:none;border:hidden;" readonly name="q'.$i.'" value="'.$Question.'"></td> </tr> <tr> <td height="32" width="50%"><input type="radio" name="ans'.$i.'" value="A" id="OptionA" /> '.$OptionA.'</td> <td width="50%"><input type="radio" name="ans'.$i.'" value="B" id="OptionC" /> '.$OptionC.'</td> </tr> <tr> <td height="32" width="50%"><input type="radio" name="ans'.$i.'" value="C" id="OptionB" /> '. $OptionB.'</td> <td width="50%"><input type="radio" name="ans'.$i.'" value="D" id="OptionD" /> '.$OptionD.'</td> </tr> </table></td>'; } if($Id=='T/F') { echo '<tr> <td>('.$i.')</td><td height="36" colspan="2" bgcolor="#85A157"><span class="style1"></span> <tr>say True or False</tr> <input type="text" name="ans'.$i.'" style="margin-left:4px;width:25%;background-color:white;border:none;" value=""></td> <td><input type="text" style="width:auto;background:none;border:hidden;" readonly name="q'.$i.'" value="'.$Question.'"></td> </tr>'; } if($Id=='Filling'){ echo '<tr> <td>('.$i.')</td><td height="36" colspan="2" bgcolor="#85A157"><span class="style1"></span> <tr> Falling the space</tr> <input type="text" name="ans'.$i.'" style="margin-left:4px;width:25%;background-color:white;border:none;" value=""></td> <td><input type="text" style="width:auto;background:none;border:hidden;" readonly name="q'.$i.'" value="'.$Question.'"></td> </tr>'; } ?> <p> <?php $i=$i+1; } ?> </p> <p align="center"> </p> <div align="center"> <?php // Retrieve Number of records returned $records = mysql_num_rows($result); if($records!=0) { ?> <input type="text" hidden name="total" value="<?php echo mysql_num_rows($result);?>"> <input type="submit" name="button" id="button" value="Submit" /> <?php } // Close the connection mysql_close($con); } /*elseif(!mysql_num_rows($result)) { echo 'not access the exam'; } elseif(mysql_num_rows($result)) { echo 'not aceess the exam'; } else { echo" not access the exam"; }*/ ?> </div> </form> <p>&nbsp;</p> <h1>&nbsp;</h1> </div> <div id="footerline"></div> <div id="footer">Copyright &copy; 2017 JJU Online Examination System.<br/> All rights reserved.&nbsp;</div> </div> </body> </html>
  2. skyhighweb

    am having tpl isuue

    how do i convert this <select name="willwin" id="willwin"> <?php if ($db->numrows() > 0){ while ($row = $db->fetch()) { ?> <option value=''></option> <option value="<?php echo $row["willwin"]; ?>"><?php echo $row["team1"]; ?></option> <option value="<?php echo $row["willlose"]; ?>"><?php echo $row["team2"]; ?></option> <?php } } ?> </select> <br/><br/> <label>Tag Bettor</label> <select name="sub_cat" id="sub_cat"></select> to look like this $TPL_team_list = '<select name="willwin" class="form-control">' . "\n"; while ($row = $db->fetch()) { $TPL_team_list .= "\t" . ' <option value="' . $row[''] . '" ' . $selected . '>' . $row[''] . '</option> <option value="' . $row['team1'] . '" ' . $selected . '>' . $row['team1'] . '</option> <option value="' . $row['team2'] . '" ' . $selected . '>' . $row['team2'] . '</option> ' . "\n"; } $TPL_team_list .= '</select>' . "\n"; { $template->assign_block_vars('tag_bidder', array( 'TEAM' => $TPL_team_list, )); $i++; } i cant intergrate the above form (doesnt respond when place directly) in tpl unless converted
  3. Balderick

    placing a function inside an if condition

    Sorry people here I have asked this before, so its a bit embarassing to me. But .... I have the following question. Its about using a function inside an if condition. The thing is that when I make a function with 2 returns in this case $data and $alternative I receive them both back. I ask this for grasping how a function acts inside an if condition. So my question is: how does the php engine ‘reason’? Is the outcome of the return ONLY POSSIBLE if you return 1 value inside an if condition; so either true or false ? Example: <?php function valid_someting($data){ global $alternative; $count=''; $count = strlen($data); if ( ($count < 8 && ($count > 4) ) ) { $data = preg_replace('/[^a-zA-Z0-9!@#$%^&*()\-_=+{};:,<.>]/', '', $data ); // $data = ltrim($data); $data = rtrim($data); return $data; } $alternative = $data; return $alternative; } $data = 'abcdabcdabcd'; if (valid_someting($data)) { echo 'color input field green'; } else if ($alternative == TRUE) { echo 'color input field RED'; } ?>
  4. Balderick

    risky password input examples

    I have a security question. Though I have gone through OWASP docs I still need to place specific things in the right perspective. It is actually quite brief regarding examples. But regarding security, I have to admit that I dont know much about how hackers are operating. What I know is that javascript can be included and mysql injection can be done if you don't escape well. I have a piece of regex to allow as much characters as possible for password input. So also the <> the dot . and the semi-colon ; and the string. After forcing the user to use the right characters the password is encrypted with blowfish. Im actually not sure what happens, because if you encrypt malicious code, you can finally make it work again when you decrypt it. Probably its naive to ask online for hacking examples, because then you inform hackers. Maybe if you cant make up any risky situation, you can give a recommendation for which characters should be avoided for a password input. All input is encryted with password_verify / Blowfish. Then prepared OOP queries store the variable in the database. regex: $var='/[!@#$%^&*()\-_=+{};:,<.>]/'; then the preg_replace does: if(preg_match_all($var,$pas_inp, $o)<2) { echo '<br><br>input should contain at least 2 special chars , try again'; return FALSE; } How risky (in which possible situations) is the use of: < > . ; $ & regarding javascript, mysql injection and other possible hacks. (sorry it is a very open question, but to avoid problems I have to start somewhere)
  5. Hello! As you can see on my site there are three sections that include members with pictures. I need to only remove the middle one ( I have uploaded a picture that shows the exact section). I have located the point where the code is but I am not sure of what I should delete for I am afraid it might break the site. The website is www.gpseminars.gr and here is the part of the code I believe needs to be modified. <!--- ============ STAFFS =========== ------------> <div class="clear"></div> <div id="staff-box-item"> <h2 class="boxtoptitle" ><?php echo esc_attr(innovation_get_option('staffboxes-heading', 'WE ARE INSIDE')); ?></h2> <h4 class="boxtopdes" ><?php echo esc_textarea(innovation_get_option('staffboxes-heading-des', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua')); ?></h4> <div id="grid-staff" class="main"> <?php foreach (range(1, 3 ) as $staffboxsnumber ) { ?> <div class="view-staff" > <div class="view-staff-name"> <h3><?php echo esc_attr(innovation_get_option('staffboxes-title' . $staffboxsnumber, 'OUR PROUD STAFF '. $staffboxsnumber )); ?></h3> <p><?php echo esc_attr(innovation_get_option('staffboxes-description' . $staffboxsnumber, 'Service Executive' )); ?></p> </div> <div class="view-staff-back social-link"> <a href="<?php echo esc_url(innovation_get_option('staffboxes-linka' .$staffboxsnumber, 'http://wordpress.org' )); ?>"></a> <a href="<?php echo esc_url(innovation_get_option('staffboxes-linkb' .$staffboxsnumber, 'http://wordpress.org' )); ?>"></a> <a href="<?php echo esc_url(innovation_get_option('staffboxes-linkc' .$staffboxsnumber, 'http://wordpress.org' )); ?>"></a> <a class="profile-link" href="<?php echo esc_url(innovation_get_option('staffboxes-link' . $staffboxsnumber, '#' )); ?>">&rarr;</a> </div> <img src="<?php echo esc_url(innovation_get_option('staffboxes-image' . $staffboxsnumber, get_template_directory_uri() . '/images/stf'. $staffboxsnumber . '.jpg')); ?>" /> </div> <?php } ?> </div> </div> <!--- ============ END OF STAFFS =========== ------------> THANK YOU IN ADVANCE.
  6. Hi,As the title said, i'm trying to update an SQL Server DB with php. From my code below, you can see that i call once a stored proc to get information who will be in a table. One of the row allow me (supposed to be)(the last row who is an input), to change an other one (row name GL). But with the button save, it seems like nothing change at all. I tried to make some log with console and i can see test1 and test2. So it seems like it can go throught but doesnt ajust anything. I really don't know anymore and i really need your help. Any ideas or help will be really really appreciate. More on that, i'm not sure if i do it well about sql injection... <?php if(isset($_POST["test"])) { $NewValue = $_POST["noGL" . $_POST["TLZno"]]; $TLZ = $_POST["TLZ"];?> <script> console.log ("test1"); </script> <?php $sql1 = "UpdateGL @CIE ='RAL', @TLZ='$TLZ', @NOGL='$NewValue'";?> <script> console.log ("test2"); </script> <?php } else { echo "Rien!"; } ?> <button class="btn btn-success btn-sm dropdown-toggle save" name='submit' id='submit' type="submit" value="Enregistrer"> <i class="fa fa-floppy-o fa-lg" aria-hidden="true"> Enregistrer</i> </button> <script> $(document).ready(function(){ $('.save').click(function(){ $('#GL_form').submit(); }); }); </script> </div><!-- Fin class pull-left--> <div class="panel panel-primary filterable"> <div class="panel-heading"> <h1 class="panel-title" style="font-weight:bold;">Liste des numéros de GL</h1> </div><!--Fin class panel-heading--> <div class="table-responsive"> <form id="GL_form" method="post" action="ListeGL.php"> <input type="hidden" id="test" name="test"/> <table id="employees" class="table table-highlight"> <thead> <tr class="filters" id="filters"> <th style="text-align: center;"># TLZ</th> <th style="text-align: left;">Description</th> <th style="text-align: center;">D/C</th> <th style="text-align: center;"># GL</th> <th style="text-align: left;">Nouveau # GL</th> </tr> </thead> <tbody> <?php $sql = "ListeGL"; $result = sqlsrv_query($conn, $sql); $row_count = sqlsrv_num_rows($result); while ($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) { //print_r( $row ); // debug code $couleur='black'; $font= 'normal'; $input="a"; if( strstr($row['HTML_CODE'], "BOLD()")){ $font= 'bold'; } if( strstr($row['HTML_CODE'], "BG()")){ $font2= '#D8D8D8'; } if( strstr($row['HTML_CODE'], "INPUT()")){ $input= 'input'; $font2= '#transparent'; } ?> <tr> <?php echo "<tr style=\"font-weight:$font; color:$couleur; background-color:$font2;\">"; ?> <td style="text-align: center;"><?php echo ($row['TLZno']); ?></td> <td style="text-align: left;"><?php echo ($row['TlzDescription']); ?></td> <td style="text-align: center;"><?php echo ($row['TlzType']); ?></td> <td style="text-align: center;"><?php echo ($row['noGL']); ?></td> <td style="font-weight: normal; text-align: left; color: #BDBDBD; "> <<?php echo $input . ' name="noGL' . $row['TLZno'] . '"'; ?> type="text" name="new" value="<?php echo ($row['noGL']); ?>" /> </td> </tr> <?php } ?> </tbody> </table> </form>
  7. BACKGROUND: I am tempted to write something like the following foreach ($non-matches as $key => $val) { echo '<script> $("#' . $key . '").append("<p style=' . '"color:red;">Complete this item!</p>);</script>)'; } QUESTION ONE: Under the assumption that the echo statement is correct would you recommend this as proper programming procedure? If not, please explain why and provide an alternative, more appropriate strategy that would achieve the same objective suggested by the use of a jQuery object ? QUESTION TWO: If it is proper programming procedure, please correct the echo statement so that it will achieve the following: $("#...").append("<p style='color:red;'>Complete this item!</p>"); EDIT: In order to assist you in your response, the PHP variable $non-matches contains a list of values for the id attributes of form input control tags that have been carefully selected through a prior PHP procedure. An alternative approach that is currently under consideration is to create a JSON object, assign it to a Javascript variable, and iterate the resulting object with jQuery.
  8. Junitar

    Removing specific items from a list

    Hi, I would like to list all the items contained in a folder except for 2 or 3 specific ones. For example, let's say I've item 1, item 2, …, item 10 in /myFolder. I would like to list all the items of /myFolder but item 1, item 3 and item 4. I've come up with the following code which does the work but looks a bit awkward. <?php $dir = '/myFolder'; $filesDir = new FilesystemIterator($dir, FilesystemIterator::SKIP_DOTS); $fileName = ''; foreach ($filesDir as $file) { $fileName = $file->getBasename(); if ($fileName != 'item1' && $fileName != 'item3' && $fileName != 'item4') { echo $fileName.'<br>'; } } Is there a simple and more elegant way to accomplish this? Any help would be appreciated, thanks!
  9. BACKGROUND: The following routine takes a nested, associative array whose end-values are empty, extracts the keys of each non-recursive subarray, and properly echoes each. Rather, than returning the result as a newly constituted array, however, the function returns boolean true and displays the desired result in a non-useable form. Now, I have tried in vain to get the call-back function to produce an index-array of the echoed values that I can use outside the scope of the array_walk_recursive( ) function, but have failed miserably. QUESTION: How does one produce from the function a useable array that can be used outside of the function. $result = array_walk_recursive($insertion_vars, function($key, $value) { echo $value . '<br />'; });
  10. QUESTION: How does one manipulate jQuery in a $( document ).ready( function( ) {...}); with PHP? Is it even possible? BACKGROUND: I have created a form whose performance depends on a combination of both PHP and jQuery. Unfortunately, I cannot get the two sets of code to synchronize properly. A seasoned programmer would probably tell me to start over and use one or the other, but not both. Unfortunately, there are things that I know how to do in Javascript, but not in PHP, and vice versa. It is because of this that I have gotten myself into this mess.
  11. First off, thanks for letting me into the forums. Excuse a newbie but I have a question about fetching data from a database with PHP and AJAX. Let's say I wanted to fetch data from the database like in this example from W3Schools, but I had modified the dropdown to for example fetch all entries with last name Griffin, Swanson or Quagmire. I made the q variable take a string instead of an integer. $q = strval($_GET['q']); Now I want to expand the SQL query to also take another condition. "SELECT * FROM user WHERE LastName = '".$q."' AND Hometown = '".$q2."'"; I understand how to build the query and that I need to declare another variable (q2), but how do I modify the AJAX request? xmlhttp.open("GET","getuser.php?q="+str,true); Also, would I need to have a submit button now that there are two conditions? Thanks!
  12. Winnetouch

    PHP contact form

    Hello. A couple of weeks ago I concluded a couple of front end development courses and we only touched upon php coding. Since we didn't do much of it I used w3schools.com to learn some basics. I used the tutorial to make a contact form but I have a little problem. Currently the form is set (or rather was until I removed some code) to show anything that was entered in to the form on the site (basically like in this tutorial: https://www.w3schools.com/php/php_forms.asp). What I want the form to do is send the entered information to a predefined email address. But that's not all. It's going to be used on a singlepage website layout. I want the form to also show a prompt box that warns the user that either something went wrong or that the message was sent and reload the page back to the same position (I realise I need to use index#pageposition to do this but I don't know how to implement the link). Currently this only warns the user of what he did wrong (but not in a prompt box that something wrong happened) and reloads the page to the top. I'm a PHP noob (big noob), and I would appreciate if someone can help me out with this. Thank you :). <?php // define variables and set to empty values $nameErr = $emailErr = $genderErr = $websiteErr = ""; $name = $email = $gender = $comment = $website = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Vpiši ime!"; } else { $name = test_input($_POST["name"]); if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Dovoljene so samo črke in presledki!"; } } if (empty($_POST["email"])) { $emailErr = "Vpiši email naslov!"; } else { $email = test_input($_POST["email"]); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Vpišite veljaven email naslov!"; } } if (empty($_POST["subject"])) { $subjectErr = "Vpiši naslov sporočila!"; } else { $subject = test_input($_POST["subject"]); } if (empty($_POST["message"])) { $messageErr = "Vpiši sporočilo!"; } else { $message = test_input($_POST["message"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <!DOCTYPE html> <html> <link rel="stylesheet" href="style.css" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet"> <meta name="kontakt"> <head> </head> <body> <div class="col-md-12"> <div class="form-area"> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <br style="clear:both"> <h3>Piši nam</h3> <div class="form-group"> <input type="text" class="form-control" name="name" placeholder="Ime"> <span class="error">* <?php echo $nameErr;?></span> </div> <div class="form-group"> <input type="text" class="form-control" name="email" placeholder="Email"> <span class="error">* <?php echo $emailErr;?></span> </div> <div class="form-group"> <input type="text" class="form-control" name="subject" placeholder="Naslov"> <span class="error">* <?php echo $subjectErr;?></span> </div> <div class="form-group"> <textarea class="form-control" type="textarea" placeholder="Sporočilo" name=message rows="8"></textarea> <span class="error">* <?php echo $messageErr;?></span> </div> <input type="submit" class="btn btn-primary" name="submit" value="Submit"> <!--<button type="button" name="submit" class="btn btn-primary pull-right" value="Submit">Pošlji</button>--> </form> </div> </div> </body>
  13. iwato

    The header( ) Function

    DISCLAIMER: After seeing what has been written on the internet on this subject I am loathe to start here, but have I any other choice? QUESTION: The PHP header(location: './sample.html'); is telling me that my headers have already been sent and is referring me back to the beginning of my PHP script. Can I buffer my way out of this mess? If so, Where to I start and stop the buffer? Where do I place the header( ) function? BACKGROUND: I have just spent several weeks setting up an email verification system and am putting on the decorative touches. Truly, I thought that I had almost reached the end; truly I fear now that I am far from finished. I hope that I am wrong.
  14. danjesama

    Radio Button Color On/Off

    Hi Guys, I have a table that shows information and the status of that, being on or off. the on and off part is hard to notice and as it is the most valuable I was hoping to change it from simple text of on/off to a green/red circle. At the moment I am using a text input in a form for on/off. I have looked around and haven't found much related to this. I am having to replace the text input box with the radio button and if its clicked it will show green and if not it will show red. any suggestions on this? I will attach my code below: input form: <th>Repo Status: * <td><input type="text" name="status" value="<?php echo $status; ?>" /></td></tr> Displayed Table: echo '<td>' . $row['status'] .'</td>'; Thanks in advance
  15. Hi Guys, I have a form adds details to a table and one of them is owner email which takes in an email address. this in turn displays this email address on the form. What I am looking to do is for the form have the user just put in there username and the email address is automatically attached at the end(as all the details after@ in the email address will be the same). Then when the table is displaying the email address it just displays the username which when clicked still brings you to a new email to that email address. Images: so here it would be just username and @whatver.com is always on the form and here it just displays the username so dmurran instead of the whole email address. here is the code for the table: // display data in table echo "<table align='center' border='1' cellpadding='2' class='footable mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--4dp full-width'>"; echo "<tr> <th>ID</th> <th>Administration Console</th> <th>Product Version</th> <th>Platform</th> <th>Database</th> <th>Owner</th> <th>Status</th> <th></th> <th></th></tr>"; // loop through results of database query, displaying them in the table while($row = mysql_fetch_array( $result )) { // echo out the contents of each row into a table echo "<tr>"; echo '<th>' . $row['id'] . '</th>'; echo '<td><a href="'.$row['curl'].'">'.$row['curl'].'</a></td>'; echo '<td>' . $row['pversion'] . '</td>'; echo '<td>' . $row['platform'] . '</td>'; echo '<td>' . $row['dversion'] . '</td>'; echo '<td><a href="mailto:'.$row['email'].'">' . $row['email'].'</a></td>'; echo '<td>' . $row['status'] .'</td>'; echo '<td><a href="php/edit.php?id=' . $row['id'] . '">Edit</a></td>'; echo '<td><a onclick="javascript:confirmationDelete($(this));return false;" href="php/delete.php?id=' . $row['id'] . '"onclick="return confirm("Do you want to delete this?")">Delete</a></td>'; echo "</tr>"; } // close table> echo "</table>"; ?> and here is the form: <?php /* NEW.PHP Allows user to create a new entry in the database */ // creates the new record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($curl, $pversion, $platform, $dversion, $email, $status, $error) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="../css/style.css"> <link href='../css/bootstrap.cs' rel='stylesheet'> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src='../js/bootstrap.js'></script> <title>New Repo</title> </head> <body> <div id="page-wrap"> <center><a href="https://repo-project-danielmurran.c9users.io/view.php"><img src="../images/logo.png" alt="what image shows" height="90" width="300"></a></center> <h1>GCS Reproduction Environment</h1></br> <button type="button" onclick="window.location='https://repo-project-danielmurran.c9users.io/view.php'">Home</button> <hr/> <h2> Add Reproduction</h2> <?php // if there are any errors, display them if ($error != '') { echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>'; } ?> <form action="" method="post"> <div id="bform"> <table id="maintable" border='1' cellpadding='10'> <thead> <tr> <th>Repoduction Console URL: *<td><input type="text" name="curl" value="<?php echo $curl; ?>" /></td> </tr> <th>Product Version: *<td> <input type="text" name="pversion" value="<?php echo $pversion; ?>" /></td></tr> <th>Platform: * <td><input type="text" name="platform" value="<?php echo $platform; ?>" /></td></tr> <th>Database: * <td><input type="text" name="dversion" value="<?php echo $dversion; ?>" /></td></tr> <th>Owner Emaill: * <td><input type="email" name="email" value="<?php echo $email; ?>" /> </td></tr> <th>Repo Status: * <td><input type="text" name="status" value="<?php echo $status; ?>" /></td></tr> </table> * required <input type="submit" name="submit" value="Submit"> </div> </form> </div> </body> </html> <?php } // connect to the database include('../php/connect-db.php'); // check if the form has been submitted. If it has, start to process the form and save it to the database if (isset($_POST['submit'])) { // get form data, making sure it is valid $curl = mysql_real_escape_string(htmlspecialchars($_POST['curl'])); $pversion = mysql_real_escape_string(htmlspecialchars($_POST['pversion'])); $platform = mysql_real_escape_string(htmlspecialchars($_POST['platform'])); $dversion = mysql_real_escape_string(htmlspecialchars($_POST['dversion'])); $email = mysql_real_escape_string(htmlspecialchars($_POST['email'])); $status = mysql_real_escape_string(htmlspecialchars($_POST['status'])); // check to make sure all fields are entered if ($curl == '' || $pversion == '' || $platform == '' || $dversion == '' || $email == '' || $status == '') { // generate error message $error = 'ERROR: Please fill in all required fields!'; // if either field is blank, display the form again renderForm($curl, $pversion, $platform, $dversion, $email, $status, $error); } else { // save the data to the database mysql_query("INSERT INTO players SET curl='$curl', pversion='$pversion', platform='$platform', dversion='$dversion', email='$email', status='$status'") or die(mysql_error()); // once saved, redirect back to the view page header("Location: ../view.php"); } } else // if the form hasn't been submitted, display the form { renderForm('','','','','','',''); } ?> I tried to cut off the end of the email but it was not bringing me to the email address anymore. Any help is appreciated. Thanks!
  16. BACKGROUND: I am setting up an email verification routine that receives $_POST data from a form and sends a confirmation email to the applicant with a verification link. The form and the PHP processing routines that store the $_POST data in a MySQL database, and that send out the confirmation email in text format are contained in the same document. The HTML formatted confirmation email is contained in an external file and is included using the following PHP-Mailer method: $mail->msgHTML(file_get_contents('../../confirmation_mail.html'), dirname(__FILE__)); GOAL: Include in the external HTML file information obtained from the $_POST variable before the email is sent. WHAT DOES NOT APPEAR TO WORK: I have tried placing statements similar to <?php echo "blah, blah, blah" . $variable_name . "blah, blah, blah"; ?> in the external file in the hope that the value of $variable_name would be read into the file before it is sent. Unfortunately, this does not work. ANY SUGGESTIONS?
  17. Hello, I've just read the tutorial on how to process a form in PHP, available on this site, and I was wondering if there's a specific reason to declare empty variables (or arrays) at the beginning? I don't understand what is the point of doing so. For example, in the following code, why would the 2sd and 3rd lines be necessary? <?php $errors = []; $name = $email = $message = ''; if (condition) { $errors['name'] = 'alert'; } else { $name = sanitize_input($_POST['name']); if (new_condition, $name) { $errors['name'] = 'new alert'; } }
  18. Kevin Castro

    Xampp is not working

    Hello folks, I installed a XAMPP Version 7.0.15 on my windows 7(32-bit) computer but it doesn't work properly.When i open in the browser it shows "The site can't be reached". What's the solution for it? please help me. Thank you in Advance..
  19. I am starting my first serious php project. I have been following tutorials, to get up to speed with mysql and php programming and decided that it is a good time to move forward. My goal is an online database. For development purposes, I just chose a movie database. I would like to go to the main page and display an option to login as a user. The users are basically persons who edit the database. So when the user logs in, they will be able to update a basic profile with some simple user info and they will be able to add, delete or update records from the database. Working with mysql to add, delete or update records as a task, I have recently completed. Still rounding out how to do that, but I have a good grasp of this now. What I don't know, is how to fit a login system into the project. For sure, I am using PHP procedural. I don't want to work with object oriented code for now. I also know by recommendation, that I want my user database to be a table in my database instead of a separate db. So I am starting a very simple login system from scratch. Does anyone have a recommendation on how I can start this. What pages should I create and how should I structure the code. This is my first project where I have to think of various angles corresponding to my web application. So, I'm new to having to solve different problems related. Not too overwhelming, but if you can keep it simple or step by step for me, it would really be helpful. Any suggestions?
  20. danjesama

    Adding a Delete Warning to PHP

    Hi guys, I have a table with a delete column with deletes individual rows from the column, I am looking to add a delete warning. Now I know you can add a javascript function but im unsure how to do this as my page is built in PHP. Here is the delete column: echo '<td data-sort-initial="Descending"><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>'; Here is my delete.php file: <?php /* DELETE.PHP Deletes a specific entry from the 'players' table */ // connect to the database include('connect-db.php'); // check if the 'id' variable is set in URL, and check that it is valid if (isset($_GET['id']) && is_numeric($_GET['id'])) { // get id value $id = $_GET['id']; // delete the entry $result = mysql_query("DELETE FROM players WHERE id=$id") or die(mysql_error()); // redirect back to the view page header("Location: view.php"); } else // if id isn't set, or isn't valid, redirect back to view page { header("Location: view.php"); } ?> Thanks in advance
  21. rootKID

    login dosent work, code correct?

    Hi W3S I am trying to make a login PHP code with MySQLI and it won't work for some reason, not sure what i have done wrong, can someone see what i did wrong? This is the code: //////////////////////////////////////////////////////////////////////////////////////////////////////// // Login //////////////////////////////////////////////////////////////////////////////////////////////////////// $SUBMIT_FORM_ACTION___TakeLoginForm = (isset($_GET["SUBMIT_FORM_ACTION"]) ? $_GET["SUBMIT_FORM_ACTION"] : ""); if( $SUBMIT_FORM_ACTION___TakeLoginForm == "TakeLogin" ) { $query_1 = "SELECT u_id, u_username, u_password, u_email FROM users WHERE u_email=? AND u_password=?"; if ( $stmt = $mysqli->prepare($query_1) ) { $FORM_email = $_POST['email']; $FORM_password = $_POST['password']; $stmt->bind_param('ss', $FORM_email, $FORM_password); $stmt->execute(); $stmt->bind_result($id, $username, $password, $email); $stmt->fetch(); // SECURITY! CHECK & COMPARE! if($FORM_password !== $password) { die(" <center><b>(Form) Login ErrMSG #1</b></center> <br /> <center>Password incorrect/wrong! Try again!</center> "); } // Make Sessions Needed! $_SESSION['user'] = array(); $_SESSION['user']['id'] = $id; $_SESSION['user']['username'] = $username; $_SESSION['user']['password'] = $password; $_SESSION['user']['email'] = $email; $stmt->close(); //header("location: index.php"); } } okay so lets see if i get this straight. In the bind_result part, this does not matter what kind of variable it is right? In the naming part... or does the names actual HAS to be like the ones in the Database Columns? I somehow think its the part there but correct me if i am wrong... Hoping someone can help me a little bit. Thanks in advance
  22. Goat

    Is this safe?

    I was wondering is there is any vulnerabilities in this code: <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } // Check if file already exists if (file_exists($target_file)) { echo "Sorry, file already exists."; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 500000) { echo "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; } else { echo "Sorry, there was an error uploading your file."; } } ?> cause I know attackers can put a virus in images and I don't want any viruses on my website. Also I wanted to know one more thing. How could I make it so that users can only upload a certain size of image like 50x50? The code used in this thread came from this page: https://www.w3schools.com/php/php_file_upload.asp
  23. shah_ankitb

    Payment gateway change method after duration

    I'm using eCommerce. Once done payment it should be captured & after few days it should be processed or deducted from customers account. Example: If the customer pays using Paypal initial it would be "Authorize" & after (Max 21 days) that particular transaction is converted in to "Sale" means processed. Customers can pay using Credit Card. Can we achieve using Paypal or need to use another Payment Method? As per my knowledge: In Paypal SDK API you have to create that Payment Again & then Process. But I already have Transaction Id. So need to create payment again right?
  24. darbok

    wordpress, mybbs, wiki.

    is there a way to make a singular login for a wordpress website that also logs a person into the forums and the wiki at the same time?
  25. darbok

    connecting to msqli

    Looking at how form items are put into a mysql table, the part that seems daunting is if ones form has like 50 items... having to list all those IDs with their variables makes me wonder if there is a better way or if its just " it up buttercup.".
×