This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-09-16 13:59:10

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Get :d

Hello all, so I am making a web application (secret for now  tongue  ) and I need some help on this one part.

You see, the main idea you need to know is, you type something out in a list, then press a button, and it creates a pdf file for you with the content you typed. But for some reason, either the POST or GET is not cooperating correctly.

Help?  big_smile

Heres the code that you need:
(not all of it)
First Page:

Code:

$title = "Edit List Title";
$date="Edit List date";
$list = array("","","","");
$title1 =$_POST['title'];
$date1=$_POST['date'];
for($j = 1; $j < 5; $j++){
    $list1 =array($_POST['list'. $j]); 
}
echo"<span id='cmd'><a onclick='clear()'>New</a><a href='pdf.php?title=$title1&list1=$list1[0]&list2=$list1[1]&list3=$list1[2]&list4=$list1[3]&date=$date1'>Save</a><a onclick='alert(this)'>Exit</a></span>
<form method='post'><div id='doc'><div id='title'><input type='text' class='big' name='title' value='$title'/><br/>
Date: <input type='text' class='norm' name='date' onKeyPress='return numbersonly(this, event)' value='$date'/>";
for($i = 1; $i < 5; $i++){
    echo "<div class='item'><div class='entry'><span>$i.</span><input type='text' class='norm' name='list" . $i . "' value='$list[$i]'/><img src='check.png'/></div>";
}
echo"</form></div>";

Second Page (pdf.php)

Code:

<?php
$title = $_GET['title'];
$date = $_GET['date'];
for($j = 1; $j < 5; $j++){
    $list = $_GET['list' .$j];
}
/*////////////////////////////////////////////*/
/*       Create PDF File                                              */
/*////////////////////////////////////////////*/
try {
    $p = new PDFlib();

    /*  open new PDF file; insert a file name to create the PDF on disk */
    if ($p->begin_document("", "") == 0) {
        die("Error: " . $p->get_errmsg());
    }

    $p->set_info("Creator", "hello.php");
    $p->set_info("Author", "NTJ, ListDu");
    $p->set_info("Title", "$title");

    $p->begin_page_ext(595, 842, "");

    $font = $p->load_font("Helvetica-Bold", "winansi", "");

    $p->setfont($font, 24.0);
    $p->set_text_pos(50, 700);
    $p->show("$date");
    $p->continue_text("$list");
    $p->end_page_ext("");

    $p->end_document("");

    $buf = $p->get_buffer();
    $len = strlen($buf);

    header("Content-type: application/pdf");
    header("Content-Length: $len");
    header("Content-Disposition: inline; filename=$title-LISTDU.pdf");
    print $buf;
}
catch (PDFlibException $e) {
    die("PDFlib exception occurred in hello sample:\n" .
    "[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
    $e->get_errmsg() . "\n");
}
catch (Exception $e) {
    die($e);
}
$p = 0;
?>

Offline

 

#2 2011-09-16 14:09:44

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Get :d

Try changing the pdf.php file to use $_POST and using these small changes:
Form tag: <form action="pdf.php" id="frm" method="post">
Save link: <a href='javascript:document.getElementById(\"frm\").submit();void(0);'>Save</a>

May not work, but worth a go!  smile


/* No comment */

Offline

 

#3 2011-09-16 14:27:53

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Get :d

TheSuccessor wrote:

Try changing the pdf.php file to use $_POST and using these small changes:
Form tag: <form action="pdf.php" id="frm" method="post">
Save link: <a href='javascript:document.getElementById(\"frm\").submit();void(0);'>Save</a>

May not work, but worth a go!  smile

Thanks! I had to do a few more things, but in the end, it worked!  big_smile 
I'll be announcing the name and purpose soon!  big_smile

Offline

 

#4 2011-09-16 14:30:24

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: Get :d

Let me guess, PDF maker!


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#5 2011-09-16 14:42:22

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Get :d

WindowsExplorer wrote:

Let me guess, PDF maker!

Duh. But its different than just that.  tongue

Offline

 

#6 2011-09-16 14:45:06

wulfmaster
Scratcher
Registered: 2011-04-23
Posts: 500+

Re: Get :d

ProgrammingFreak wrote:

WindowsExplorer wrote:

Let me guess, PDF maker!

Duh. But its different than just that.  tongue

yikes   I want to know what else it does!  tongue
Well then, hurry up mate!  Then will you do some PHP for rocket?  hehehe.


Social Connections - Bringing communities close together! http://cyberkidscountry.com/ip.php

Offline

 

#7 2011-09-16 15:15:28

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Get :d

wulfmaster wrote:

ProgrammingFreak wrote:

WindowsExplorer wrote:

Let me guess, PDF maker!

Duh. But its different than just that.  tongue

yikes   I want to know what else it does!  tongue
Well then, hurry up mate!  Then will you do some PHP for rocket?  hehehe.

Um, sure!  big_smile

Offline

 

#8 2011-09-16 15:17:23

wulfmaster
Scratcher
Registered: 2011-04-23
Posts: 500+

Re: Get :d

ProgrammingFreak wrote:

wulfmaster wrote:

ProgrammingFreak wrote:


Duh. But its different than just that.  tongue

yikes   I want to know what else it does!  tongue
Well then, hurry up mate!  Then will you do some PHP for rocket?  hehehe.

Um, sure!  big_smile

lol thanks.   smile
I'm trying to get rocket started up again!  smile
(You do realise who I am, right?)


Social Connections - Bringing communities close together! http://cyberkidscountry.com/ip.php

Offline

 

#9 2011-09-16 15:25:35

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: Get :d

wulfmaster wrote:

ProgrammingFreak wrote:

wulfmaster wrote:


yikes   I want to know what else it does!  tongue
Well then, hurry up mate!  Then will you do some PHP for rocket?  hehehe.

Um, sure!  big_smile

lol thanks.   smile
I'm trying to get rocket started up again!  smile
(You do realise who I am, right?)

Yay! And yeah. Youre ssss.  tongue

Offline

 

#10 2011-09-16 15:27:19

wulfmaster
Scratcher
Registered: 2011-04-23
Posts: 500+

Re: Get :d

ProgrammingFreak wrote:

wulfmaster wrote:

ProgrammingFreak wrote:


Um, sure!  big_smile

lol thanks.   smile
I'm trying to get rocket started up again!  smile
(You do realise who I am, right?)

Yay! And yeah. Youre ssss.  tongue

Lol.  smile
As soon as I help someone with there project, I'll get right on rocket!  smile


Social Connections - Bringing communities close together! http://cyberkidscountry.com/ip.php

Offline

 

Board footer