Jump to content

https save and submit problem ?


seanfacer@yahoo.co.uk

Recommended Posts

Hi im a newbie php developer and am experiencing two problems at the moment. The first and most important is that google charts can not save over https i have copied a function that should save the file but i am clueless as to how it work s and where i am going wrong with it ??? any help with this would be greatly appreciated. Secondly every time i hit submit the page first posts data and then i have to submit again before it posts the data to google charts api ?

 

Again any help would be greatly appreciated Thanks in advance ill add all the code here for you guys.

 

Saving the google chart api

 

function saveImage($chart_url,$path,$file_name)

{

if ( (!file_exists($path.$filename)) || (md5_file($path.$filename) != md5_file($chart_url)) )

{

file_put_contents($path.$filename,file_get_contents($chat_url));

 

}

return($filename);

}

 

function doSomething()

{

$local_image_path ="home/sean/img/charts/";

$imagename="some_chart_image.png";

$chart_url = $chartimage;

$image = saveImage($chart_url ,$local_image_path,$image_name);

echo "Image Saved";

}

 

$body .= "<table class='formTABLE'>

<tr>

 

<TD class='FieldCaptionTD' align='right' colspan='2'>

<input class='Button'  method='post' action='' align='right' type='submit' name='save_file' value='Save'>

<input class='Button'  method='post' action='' align='right' type='submit' name='submit_button' value='Submit'>

</center>

</TD>

</tr>

</table>";

$body .= htmlmaintsplit();

?>

<img src="/home/sean/work/some_chart_image.png" alt="" />

 

How am i to use this now to save the graph i have created ???

 

Relating to the submit button problem - this is set after the submit button though i have tried placing the submit button beneath this code but still the same problem persists

 

<form action='<?php echo $action?>' method='POST' name='bargraph' value='bargraph' chid='post_form'

onsubmit="this.action = 'http://chart.apis.google.com/chart?chid=' + (new Date()).getMilliseconds(); return true;">

Link to comment
https://forums.phpfreaks.com/topic/213553-https-save-and-submit-problem/
Share on other sites

I didn't look through all your code to see what else could be causing your problem but the first thing that sticks out is that in:

<?php
function saveImage($chart_url,$path,$file_name)
{
   if ( (!file_exists($path.$filename)) || (md5_file($path.$filename) != md5_file($chart_url)) )
   {
      file_put_contents($path.$filename,file_get_contents($chat_url));

   }
   return($filename);
}?>

 

Notice the variable name in the functions parameters list is "$file_name" but in the rest of the function, you're looking for a variable named "$filename" (without the under_score). 

 

Trying replacing "$file_name" with "$filename" and see if that helps.  You may have more problems after that, but its a start

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.