Quantcast
Channel: PHP Freaks: PHP Help
Viewing all 13200 articles
Browse latest View live

Won't read my text file

$
0
0

My code works fine for the most part, unfortunately though it doesn't seem to be reading the student.txt file. If one student is registered for a course it doesn't let anyone else register for the same course.

<?php

$students = "student.txt"; // text file for students and student number
$reg = "load.txt";

//converting a string into a variable

$name = $_POST["name"];
$number = $_POST["snumber"];
$course = $_POST["pcourse"];

//open student file and explode into an array



$found = 0;

// turning students into an array to read

$fileHandle = fopen($students, "r") or die ("Student file does not exist");

while($line=fgets($fileHandle))
{
  $drop = explode(',',$line);

  if($name==$drop[0]&&$number == trim($drop[1])) //trip to remove whitespace in student number
  {
    $found = 1;
    break; // break if found
  }
}

fclose($fileHandle);
$toRep="";

if($found==1)
{
  $fileHandle = fopen("course.txt", 'r');
  while($line=fgets($fileHandle))
  {
    $drop = explode('||',$line);

    if($drop[1]==$course)
    {
      $found = 2;  // course found
      if($drop[2]>0)
      {
        $found = 3;       // couse has seats
        $toRep= $line;
        break;
      }
    }

  }
}
else
{
  echo "Student could not be found.";
  die();
}



if($found ==1)
{
  echo "The course cannot be found";
  die();
}

if($found==2)
{
  echo "The course is full";
  die();
}


if($found==3)
{
  $loadHandle = fopen("load.txt",'r');
  while($line = fgets($loadHandle))
  {
    $drop = explode(',', $line);

    if(trim($drop[1])==$course)
    {
      echo "You have already registered for the course.";
      die();
    }
  }
}

$loadHandle2 = fopen("load.txt", 'a');

fwrite($loadHandle2,"$name,$course\n");

fclose($loadHandle2);
fclose($loadHandle);

$courseHandle = fopen('course.txt', 'r');
$whole = file_get_contents('./course.txt');// read the whole file

$drop = explode('||', $toRep);


$count = (int)$drop[2];
$count = $count - 1; // make one seat less

$newStr = $drop[0]."||".$drop[1]."||".$count."\n";  // make a new string with new seat count

$whole =str_replace($toRep, $newStr, $whole); // replace the old text with new


$courseHandle2 = fopen('course.txt', 'w');
fwrite($courseHandle2, $whole); // overwrite the entire file.

echo "Sucessfully Enrolled."

?>

aligning tables with echo

$
0
0
 
Hi, ive been trying to display 2 columns side by side with 2 select statements..   please see attached for results....   for some reason the 2nd select fetches the database values correctly but echo's them horizontally and not vertically like the first columns set of results. 
 
 
Branch            Name             Total Ever              Total Year
Barry             Rich Williams         13                       12            5 4 0 0 0 0
Brum                Lisa Williams        5
London            Stephen Eckley     4
Mythr              Debs Lovelock        0
Basing              Derek Barti            0
Devon             Barry Jims               0
Glasgow          James bonds         0
Total                                               22                       21
 
 
 
 
 
 
<table class="table table-striped  table-bordered  table-hover" style="width: auto; margin: " id="example" cellspacing="0" > <!--, table table-inverse   table-bordered     -->
 <thead >
<tr >
  <th>Branch</th>
 
  <th>Name</th>
        
          <th>Total Ever</th>
           <th>Total Year</th>
   <!--    <th>Total Year</th>    -->
  </tr>
 </thead>

<tbody >
      <?php
    
//TOTAL EVER original
$result = mysqli_query($conn,"SELECT u.company_id, u.branch, u.name ,u.surname,  u.id, count(f.date_made) as num_rows FROM users u LEFT JOIN firsts f ON u.id  = f.usr_id  where u.company_id='".$_SESSION['company_id'].  "'   group by u.id  order by num_rows DESC limit 10  ") ;
 
$result1 = mysqli_query($conn,"SELECT u.company_id,  u.branch,u.name,u.surname,  u.id, count(f.date_made) as date_mades FROM users u LEFT JOIN firsts f ON u.id  = f.usr_id AND DATE(f.date_made) and year(curdate()) = year(date_made)  where u.company_id='".$_SESSION['company_id']."'  group by u.id  order by date_mades DESC limit 10  ");

while($firsts=mysqli_fetch_array($result)){
 
 echo "<tr>";
      
  
  echo"<td>".$firsts['branch']."</td>";
  
 echo"<td>".$firsts['name']. ' '.$firsts['surname']."</td>";
      
       echo"<td>".$firsts['num_rows']."</td>";
while($firsts=mysqli_fetch_array($result1)){
echo"<td>".$firsts['date_mades']."</td>";
   
}
}
 

$result = mysqli_query($conn, "SELECT count(f.date_made) as date_madesss FROM users u LEFT JOIN firsts f ON u.id  = f.usr_id   where u.company_id='".$_SESSION['company_id']."'   ");
 
       while($firsts=mysqli_fetch_array($result)){
      echo "<tr>";
     
echo"<td>".'Total'."</td>";
echo"<td>";
//echo"<td>";
      echo"<td>".$firsts['date_madesss']."</td>";
       //echo"<td>".$firsts['date_madess']."</td>";
 

 
//TOTAL YEAR
  $result = mysqli_query($conn, "SELECT count(f.date_made) as date_mader FROM users u LEFT JOIN firsts f ON u.id  = f.usr_id  WHERE year(curdate()) = year(date_made)  and  u.company_id='".$_SESSION['company_id']."'    ");
 
       while($firsts=mysqli_fetch_array($result)){
     // echo "<tr>";
//echo"<td>".'Total'."</td>";
//echo"<td>".''."</td>";
//echo"<td>".''."</td>";
      echo"<td>".$firsts['date_mader']."</td>";

   
}
 
}
      
?>
</tbody>
</table>
</div>

Code incompatible with php 5.5 and above

$
0
0

Hi everybody, I have some code that is incompatible with php 5.5 and above, so I found myself stuck to php 5.4 which causes come other trouble an some other incompatibilities i my site 

 

here is the problematic code :

 

    <section class="full-width-bg gray-bg normal-padding get-in-touch-overlay">
        <div class="row">
            <div class="col-lg-6 col-md-6 col-sm-8 col-lg-push-3 col-md-push-3 col-sm-push-2">
<h2><span style="color: #ffffff;"><?php _e('Contact Form', 'marine'); ?></span></h2>
 
                <form class="get-in-touch contact-form" method="post">                    <?php wp_nonce_field('contact_form_submission', 'contact_nonce', true,
                        true); ?>                    <input type="hidden" name="contact-form-value" value="1" id=""/>
 
                    <div class="iconic-input"><input type="text" name="name" placeholder="<?php _e('Name*', 'marine'); ?>"> <i class="icons icon-user-1"></i></div>
                    <div class="iconic-input"><input type="text" name="email" placeholder="<?php _e('E-mail*', 'marine'); ?>"> <i class="icons icon-mail-4"></i></div>
                    <textarea name="msg" placeholder="<?php _e('Message', 'marine'); ?>"></textarea> <input type="submit"
                                                                                                            value="<?php _e('Send Message', 'marine'); ?>">
 
                    <div class="iconic-button"><input type="reset" value="<?php _e('Clear', 'marine'); ?>"> <i class="icons icon-cancel-circle-1"></i></div>
                </form>
                <div id="msg"></div>
            </div>
        </div>
    </section>
 
 
please help 
thanks 
 

PHP socket multiple source file

$
0
0

Hi Everyone,

 

I'm trying to have the first file open the socket and then call another file to proceed with diff. things. BUT i lose the socket pointer (resource) once I load the second file.

 

any ideas, please help thank you.

 

 

here is the code:

 

<?php
session_start();
 
$fp = stream_socket_client("udp://127.0.0.1:5003", $errno, $errstr);
$_SESSION['fp'] = $fp;
 
if (!$fp) { 
    echo "ERROR: $errno - $errstr<br />\n";
} else {
for ($i=1;$i<2;$i++){
callme($fp,$i);
}
   header ("refresh:0;url=client7b.php" );
 
}
fclose($fp);
 
function callme($fp,$x)
{
fwrite($fp, $x);
//echo fread($fp, 26);
 
}
?>
 
Ronen

execution fast

$
0
0

i coded a scrapper  for a web page

i added the scrapper to cron jobs of my free web hosting account

my hosting account is continuously removing the script maybe  because it is taking more than  5 seconds for execution :(
i tried to run it manually & recorded the time it only took 1-2 seconds in execution

but IDK maybe sometime that webpage response is slow & thats why it is taking that much time

i want to make my script fast please help me
 

my script look like this

$html=file_get_html("https://www.website.com");
identify div with id
strip_tags("$text","<a>");
str_replace // i am replacing some junk like &nbsp etc, i am using str_replace 5 times
htmlspecialchars // so that it dosent cause any sql error when i save scrapped stuff in db

$sql = "INSERT INTO abc(sfdf, contedfnt)
VALUES ('$dfdf', '$text')";

if ($conn->query($sql) === TRUE) {
    echo "Added";
} else {
echo "Error: " . $conn->error;
}

what can i do to make my code execute fast ?

  

 

emoji

$
0
0

 I am trying to download information from a MySQL database to excel  one of of fields has emoji's in it but they are coming out as a ? in excel. How do I get them appear as an emoji in Excel?

 

I am using

 

header("Content-type: text/csv; charset=utf-8");
header("Content-Encoding: utf-8");

 

 

Should it be something different to  utf-8 to get it to work? Google just says use utf-8

 

 

Thanks

ssh2_scp_send failing on SFTP

$
0
0

Hi Fellows,

 

I am having trouble sending a file to SFTP and error coming in line 14 

 

Warning: ssh2_scp_send(): Failure creating remote file: (null) in path on line 14

 

fyi, i have read write permissions to that sftp folder 

 

<?php

 
$server = 'sftp.my.com';
$port = '22';
$username = 'myLogin';
$passwd = 'Pa$$w0rd';
$localFile = '000001.txt';
 
 
$connection = ssh2_connect($server, $port);
if (ssh2_auth_password($connection, $username, $passwd)) {
echo "Connection successful, uploading file now...</br>";
$sftp = ssh2_sftp($connection);
$sftp = ssh2_scp_send($connection, "000001.txt", "/upload/".$localFile, 0644);
if($sftp){
echo"<h1>Success</h1>";
return ":)";
}

Attached Files

How do I pass value from <SELECT..</SELECT> attribute to <INPUT textbox?

$
0
0
      <?php
	$conn=mysqli_connect("localhost","myuuser","mypass","mydb");
	 // Check connection
	 if (mysqli_connect_errno())
	   {
	   echo "Failed to connect to MySQL: " . mysqli_connect_error();
	}
	$select_query="Select pastorname, ministryname from xphias_clients";
	$select_query = mysqli_query( $conn,$select_query);
	echo "<select name='pastorsname' id='pastorsname' class='form-control'>";
	while ($rc=   mysqli_fetch_array($select_query) )
	{
	   echo "<option value='" .$rc['pastorname'] . "'>" . $rc['pastorname'] . "</option>";
	}
	echo "</select>"; ?></td>
     <td><INPUT TYPE="TEXT" class="form-control" NAME="ministriesname" id='ministriesname' SIZE="16"></td>

     //JS
	<script type="text/javascript">
	$(document).ready(function(){
	    $('#pastorsname').change(function(){
	      var ministriesname = $(this).val();
	      $('#ministriesname').val(ministriesname);
	    });
     });
    </script>

Greetings again.

 

I need your expert advise once one.

 

I have a dropdown populated dynamically from the database.

 

Then I have an input text box.

 

What we would like to do is select a value from the dropdown list and then the value associated with the dropdown list value gets automatically populated in the textbox.

 

The issue here is that the value I need to be populated in a textbox is not part of the dropdown list.

 

For instance, the database fieldname of the value that automatically populates a dropdown is called pastorname.

 

However, the database fieldname of the value we would like to get automatically populate a textbox when associated value is selected from the dropdown, is not part of the dropdown.

 

Any ideas how to handle this?

 

Here is the current code. Many thanks for your assistance.

 

 

 

 

 


How to start developing websites in php and what are the softwares should be installed?

$
0
0

How to start developing websites in php and what are the softwares should be installed?

How to echo column name when max — Find highest value

$
0
0

Hello!!! :) Any idea how to accomplish this:

I want to echo the column name and the value of

max($obj->CAVCH1,$obj->CAVCH2,$obj->CAVCH3)

Here is the other part of the code

$serverName = "IP"; //serverName\instanceName
$connectionInfo = array( "Database"=>"DBname", "UID"=>"username", "PWD"=>"password");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

$result = sqlsrv_query($conn,"SELECT TOP (1) Events.EventDate, AVDCAV.CAVCH1, AVDCAV.CAVCH2, AVDCAV.CAVCH3 FROM AVDCAV INNER JOIN Events ON AVDCAV.IDEvent=Events.EventID WHERE CAVCH1 > 0 or CAVCH2 > 0 or CAVCH3 > 0 ORDER BY AVDCAV.IDEvent DESC");
$obj = sqlsrv_fetch_object( $result );
$maxObj = max($obj->CAVCH1,$obj->CAVCH2,$obj->CAVCH3);

Now i can only to echo the biggest value from the this 3 columns. The numbers are like 0.123 etc.

managing session file separately to include in all file

$
0
0

After logging, session will start. So i have to manage sessions.php in all my other files to manage session . Here is my login file

<?php
    if(isset($_POST['submit']))
    {
        include("connect.php");
        $user=mysqli_real_escape_string($con, $_POST['email']);
        $pass=mysqli_real_escape_string($con, $_POST['password']);
        $sql="SELECT * FROM users WHERE email='".$user."' AND password='".$pass."' ";
        $query=mysqli_query($con, $sql) or die(mysqli_error($con));
        $count=mysqli_num_rows($query);
        if($count==1)
        {
            $row=mysqli_fetch_array($query);
            session_start();
            $_SESSION['user_id']=$row['uid'];
        }
        else {
            header("location:../index.php?error=1");
        }
        if(isset($_SESSION["user_id"])) {
            header("location:../home.php");
        }
    }
?>

And in sessions.php

<?php
    session_start();
    session_regenerate_id();
    if($_SESSION["user_id"])
    {
        include("connect.php");
        $m1 = "select * from users where uid='".$_SESSION['user_id']."'";
        $m2 = mysqli_query($con, $m1);
        $m3 = mysqli_fetch_array($m2);
        $_SESSION['username'] = $m3['fname'].' '.$m3['lname'];
    }
    else
    if(!isset($_SESSION['user_id']))
    {
        header("location:index.php");
    }
?>

As the session is started in login.php itself, i get error in sessions.php 'Session is already started'. But if i remove session_start();, it redirects to index.php (login form). I am confused.

can somebody help me in this? 

 i have other files like dashboard.php, home.php... in that how do i manage session?

Contact Form

$
0
0

I am just trying to create a contact form and send it to myself. I get this error when I hit the submit button : Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\pet-shop\pet-shop\send-mail.php on line 9

$('#submit').on('click', function(){ // get form values and compose a data string var name = $("#name").val(); var email = $("#email").val(); var message = $("#message").val(); var data ='name=' + name + '&email=' + email + '&message=' + message; // AJAX call passing dataString in POST $.ajax({ type: 'POST', data: data, url: 'send-mail.php', success: function(){ // success callback console.log('message sent! :D'); } }); // prevent the default submit action return false; });

 

Here is my code: 

 

<!DOCTYPE HTML>

<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>Contact US</title>
<link rel="stylesheet" href="style.css">
 
 
 
 
 
</head>
<body>
<?php include("includes/header.html");?> 
    
    
<form name="my-form" method="POST" action="send-mail.php">  
    <input type="text" id="name" name="name" value="" placeholder="Name" />
    <input type="email" id="email" name="email" value="" placeholder="E-mail" />
    <textarea id="message" name="message"></textarea>
    <input type="submit" id="submit" value="SUBMIT" name="submit" />
</form>  
 
<?php include("includes/footer.html");?>   
</body>
</html>
 
 
 
 
<?php
 
    $to = "cole.shannon3@gmail.com";
 
    if($_POST){
        $name = $_POST['name'];
        $email = $_POST['email'];
        $message = $_POST['message'];
        mail($to, "New message from " . $name, $message, "From: $email" );
    }
?>
$('#submit').on('click', function(){
 
    // get form values and compose a data string
    var name = $("#name").val();
    var email = $("#email").val();
    var message = $("#message").val();
    var data ='name=' + name + '&email=' + email + '&message=' + message;
 
    // AJAX call passing dataString in POST
    $.ajax({
        type: 'POST',
        data: data,
        url: 'send-mail.php',
        success: function(){
            // success callback
            console.log('message sent! :D');
        }
    });
 
    // prevent the default submit action
    return false;
});
 

 

Getting XML Data Based Off Of URL Parameter

$
0
0

I cannot seem to figure this bit out. I'm trying to load data from an xml file depending on what the value of a url parameter is. I have an attribute set in my xml, but cannot seem to figure out how to go about this. I've looked at several examples of getting the attribute so I'm not sure where I am wrong since I haven't come across an example using url parameters to determine what data should be fetched. Here is what I have so far.

An example of my xml file. There will be more records of piercing in this file.

 

<piercings>

 <piercing id="default">
  <title>Piercing Not Specified</title>
  <names>N/A</names>
  <gauge>0</gauge>
  <healing>0</healing>
  <risk>None</risk>
  <description>You must first choose a specific piercing from the menu to view information.</description>
  <aftercare>Aftercare tips will be available once you choose a specific piercing from the menu.</aftercare>
  <avoid>Things you should avoid will be listed once a specific piercing has been chosen.</avoid>
  <img>http://via.placeholder.com/350/000000/676767?text=Not%20Specified</img>
  <additionalimgs>
   <additionalimg>http://via.placeholder.com/350/000000/676767?text=Not%20Specified</additionalimg>
  </additionalimgs>
 </piercing>

 <piercing id="incomplete">
  <title>Listing Incomplete</title>
  <names>N/A</names>
  <gauge>0</gauge>
  <healing>0</healing>
  <risk>None</risk>
  <description>The listing for this piercing is incomplete. Once completed the data will appear on this page. Please check back later.</description>
  <aftercare>Aftercare tips will be available once you the listing is complete.</aftercare>
  <avoid>Things you should avoid will be listed once the listing is complete.</avoid>
  <img>http://via.placeholder.com/350/000000/676767?text=Incomplete</img>
  <additionalimgs>
   <additionalimg>http://via.placeholder.com/350/000000/676767?text=Incomplete</additionalimg>
  </additionalimgs>
 </piercing>

 <piercing id="antieyebrow">
  <title>Anti-Eyebrow</title>
  <names>Anti-Eyebrow, Teardrop</names>
  <gauge>16</gauge>
  <healing>6 - 8</healing>
  <risk>Rejection/Migration, Scarring</risk>
  <description>The anti-eyebrow piercing is located on the upper side of the cheek bone right below the orbital socket of the eye. This piercing is most commonly pierced using a 16 gauge curved barbell or custom bent jewelry. This piercing may also be referred to as a teardrop piercing.</description>
  <aftercare>It is recommended with this piercing to clean twice a day using saline solution or antibacterial soap. Do not overclean. Irritation from overcleaning can result in migration of the piercing.
</aftercare>
  <avoid>Using rubbing alchohol as a cleaner. Changing the jewelry for atleast 3 weeks although recommended to wait until the piercing is fully healed. Pools/hot tubs especially those with chemical cleaners in them. Swimming holes, creeks, rivers, etc. due to bacterial exposure risk.</avoid>
  <img>http://jessetoxik.com/img/display/stock/antieyebrow_default.jpg</img>
  <additionalimgs>
   <additionalimg>http://jessetoxik.com/img/thumb/stock/antieyebrow_1.jpg</additionalimg>
   <additionalimg>http://jessetoxik.com/img/thumb/stock/antieyebrow_2.jpg</additionalimg>
   <additionalimg>http://jessetoxik.com/img/thumb/stock/antieyebrow_3.jpg</additionalimg>
  </additionalimgs>
 </piercing>

</piercings>

So for this one I am trying to pull all of the data for the piercing with the attribute of id="antieyebrow". Here is what I tried to retrieve that. URL: http://example.com/piercing.php?location=antieyebrow.

 

if (file_exists($_SERVER['DOCUMENT_ROOT'].'/info/piercing/piercings.xml')) {
  $piercingxml = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].'/info/piercing/piercings.xml');
  $location = $_GET['location'];
  $piercingid = $piercingxml['id'];
 }
 else {
  $piercingxml = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].'/info/piercing/default.xml');
  $location = "default";
 }

And finally to display the data onto the page:
 

echo $piercingxml->$piercingid[$location]->title;

So far nothing from the file is being displayed. How do I accomplish this?
Any help as to where I went wrong would be greatly appreciated.

 

Get error 500 when loop does 200+ iterations

$
0
0

PHP Version 5.5.9 Apache 2 100 iterations works flawlessly, but if I tried more (for example, 200), I got ERROR 500. I check memory consumption, it doesn't look so bad, about 600KB . So, IDK why it crashes to error, when I increase my iterator. I tried some tricks, but had no luck with them. IDK why, but if the script crashed to 500 error, it doesn't show me even first echos... So, I cannot to debug it by myself

Following code:

<?
//load constantes
if (is_file('config.php')) {
        require_once('config.php');
}
//set charset
ini_set("default_charset",'windows-1251');//utf-8
ini_set('display_errors', 1);
set_time_limit(600);

//create

$MyArrayOfAvailItems=array();

    for($i = 0; $i < 200; $i++) {



            $model_id   = 5000+$i;
            //echo $model_id;
            //echo '
            //      ';
            array_push($MyArrayOfAvailItems, $model_id);

    }



echo $MyArrayOfAvailItems[0];
echo '
                    ';
echo sizeof($MyArrayOfAvailItems);
echo '
                    ';

$MyArrayOfFindedItems=array();
//$item_container = "bx_catalog_item_container";
$item_container = "Сожалеем";
/* Convert, target encoding, source encoding*/
$item_container = mb_convert_encoding($item_container, "windows-1251", "utf-8");

function populateArray2($model, $data) {
    global $model;
    global $data;
    global $item_container;
    global $recurse;
    global $MyArrayOfFindedItems;
    /*
    if ($recurse === 1) {
        echo $item_container;
        echo $data;
        echo 'hello world '.$model;
        echo '
            ';
    }
    */
    $pos = strpos($data, $item_container);
    //echo $pos;
    if ($pos !== false) {
        array_push($MyArrayOfFindedItems, $model);
        echo $model;
        echo '
                ';
        //$recurse = 1;
        //populateArray2($model, $data, $recurse);
    } else {
        //echo 'not found';
    }

}
foreach ($MyArrayOfAvailItems as $model) {
    //$item_id = 5121;
    //echo $model;
    //echo '
    //              ';
    $data = file_get_contents('https://ufopeople.ru/catalog/?q='.$model);
    //echo $data;
    //echo '
    //              ';
    $recurse = 0;
    populateArray2($model, $data);

}



//echo $data;
echo '
    ';
echo memory_get_usage(true)."\n";
echo memory_get_peak_usage(true)."\n";
//echo sizeof($MyArrayOfFindedItems);
/*
foreach ($MyArrayOfFindedItems as $checkit) {
    echo '
                    ';
    echo $checkit;
}
*/

In apache logs only [core:notice] [pid 20070] AH00052: child pid 17126 exit signal Segmentation fault (11) with timings, which are not correlate to me getting Error 500.

I would appreciate any help.

Change text output position of PHP

$
0
0

Hello,

 

This code add ads in the content. I want to change the output. I tried on it but I could not solve the problem.

Thanks.

add_filter( 'the_content', 'ads_paragraphs');
function ads_paragraphs( $content ) {

$adsbeforeparagraph = array(1,3,5);

global $post;

$ad = 'ADS CODE';

$content_expl = explode("<p>", $content);
for ($i = 0; $i <count($content_expl); $i++ ) {
if (in_array($i, $adsbeforeparagraph)){
$content_expl[$i] = $ad . $content_expl[$i];
}
}

return implode("<p>", $content_expl);
}

input:

<p>text text text</p>
<p>text text text</p>
<p>text text text</p>
<p>text text text</p>
<p>text text text</p>
<p>text text text</p>

output:

<p>ADS CODEtext text text</p>
<p>text text text</p>
<p>ADS CODEtext text text</p>
<p>text text text</p>
<p>ADS CODEtext text text</p>
<p>text text text</p>

I want this output:

ADS CODE<p>text text text</p>
<p>text text text</p>
ADS CODE<p>text text text</p>
<p>text text text</p>
ADS CODE<p>text text text</p>
<p>text text text</p>

cXML punchOut with PHP

$
0
0
[[ split from https://forums.phpfreaks.com/topic/282595-cxml-punchout-with-php/ ]]

Hello @zhchow80,
 
I am trying to do the same thing, Have completed the first 3 steps, the last step is where need a little help.
Am posting data back to the requisition system via curl, got the post url from node <BrowserFormPost> but no luck.
Have created a Log of the process where can see that am sending the cxml data but not able to see the data in the requisition system
Can you please help with where can I find the POST url and is there there any POST param need to create and send or need to post raw cxml data.
 
Basically how you achieved the last step.
 
Good Day!
 
Thanks :)

XAMPP doesnt display errors?

$
0
0
Hi. I am couting on your help because I already started with programming. Well I work with XAMPP and probably server doesnt read all errors. I gather it because before XAMPP has read some errors and now display "white page". I have read somewhere that I should change on server file - PHP.ini. Error reading has to be at "On" and I set it up but still doesnt shows any error, just blank page. 
 
rvibm9dzn9w9_t.jpg
 
What can be wrong guys?

Updating php website script

$
0
0

I am using PHP as a small embedded webserver on a RPi.  Similar to how apt-get updates packages, I desire a simple means to ensure that the PHP script (not the PHP version) is up to date.  I will be able to come up with some means to initiate whatever is needed to update the scripts (i.e. a shell script for the user, a cron job, etc).  Git is not installed and not desired.  Composer seems excessive for such a small site (but maybe is a good long term solution if it grows?).  I could just scp and replace it, but there is a text config file which shouldn't be overwritten.

 

Any recommendations?  Thank you

restricting the form submission time for all users same

$
0
0

I have a form with 6 text boxes to enter numbers. When 3 or more users logs in to this page, it starts counting the seconds. each user enters some numbers to any of the text boxes. The page/form submits on each 30 seconds. When the form submits, i want to get all the data for each text box.

Here the problem is: user opens this URL and if he refreshes the page, from that time it calculates his 30 seconds, but by that time other users have finished his 20 seconds... Now my form does like this which i don't want. Form submission should not be based on user's page refresh and all. Once they join this group, it has to be same for all the users.

I am not getting how to get the server time and keep it the same for all users whoever logs in. Can somebody please help me in this?

Now i am doing like this

<form method="post" name="myForm" id="myForm" action="result.php">
         <div class="col-md-1 col-sm-2 col-xs-3">

           <input type="text" class="t1 img" name="box1[]" onKeyPress="return numbersOnly(this, event);" onpaste="return false;" />
            </div>
            <div class="col-md-1 col-sm-2 col-xs-3">
           <input type="text" class="t2 img" name="box2[]" onKeyPress="return numbersOnly(this, event);" onpaste="return false;" />
          </div>
            <div class="col-md-1 col-sm-2 col-xs-3">
             <input type="text" class="t3 img" name="box3[]" onKeyPress="return numbersOnly(this, event);" onpaste="return false;" />

            </div>
            <div class="col-md-1 col-sm-2 col-xs-3">
          <input type="text" class="t4 img" name="box4[]" onKeyPress="return numbersOnly(this, event);" onpaste="return false;" />

            </div>
            <div class="col-md-1 col-sm-2 col-xs-3">
             <input type="text" class="t5 img1" name="box5[]" onKeyPress="return numbersOnly(this, event);" onpaste="return false;" />

            </div>
            <div class="col-md-2 col-sm-2 col-xs-3">

        <img src="dice.gif" />
            </div>
            <div class="col-md-2 col-sm-2 col-xs-3">


            </div>
            <div class="col-md-1 col-sm-2 col-xs-3">
             <input type="text" class="t6 img1" name="box5[]" onKeyPress="return numbersOnly(this, event);" onpaste="return false;" />

            </div>
           <input type="button" onclick="myFunction()" value="Submit form">

 <script type="text/javascript">
    setTimeout(function(){ document.getElementById("myForm").submit(); }, 30000);

</script>

How can i set the time for all the users, it should not change even if they refresh, it has to be same for all the users.

Hope i have communicated properly.

client registration/login and file upload system with admin

$
0
0

I have been asked by current client if a client registration/login and file upload with admin system can be added to his current website, the features the client requires are below

 

1) A registration script

2) A login script with forgot password feature

3) A admin side where the client can upload files like PDF's or jpg's to the users account and enter a password to view/download the uploaded file by admin

4) The admin side to also manage the users that sign up

 

Are there any open source scripts out there that can do the above in php/mysqli or PDO?

 

Thank you in advance

Viewing all 13200 articles
Browse latest View live