Explain this code pls

balaji2u

New Member
Messages
410
Reaction score
2
Points
0
im trying to working on a template based document building script.i think this code will help me to get a input from the user such that he dont need to type the full document just the name,places of his choice must be selected and our script will generate the final document with his needed text in the placeholder like {name} {place} etc.

the code is here.pls tell me for what this code exactly for? and of these two codes which will best suit my need?
PHP:
$Sdocbuild->db_Query( "INSERT INTO `$tem_table` (`Template`) VALUES ('".$_POST['New_Template']."')" );

second code is
PHP:
    $SkaLinks->db_Query( "UPDATE `$tem_table` SET `Template`='".$_POST['Letter_tem'][$value]."' WHERE `ID`='".$value."'" );
thanks.
 

compwhizii

Banned
Messages
779
Reaction score
0
Points
0
Those are queries to a MySQL database. From what I can gather those lines of code will not do anything to help you.
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
They are simple queries to a database, but they are returned from a (I think) a class or a function.

you will probably find a bit of code above these a bit like..

PHP:
class Sdocbuild{
       function something{
       }
blah de blah
}

each class will contain a whole bunch of other variables and functions.

the symbol "->" tells you that it is returning a value from a class or function.

That said, it is also possible that these functions are in a different file; called at the beginning of the script.

If this is a template, its going to make your life very tricky.

As for the querys, the first one inserts a record with a value from a form (New_template) into a table defined by the variable $tem_table.

The second query simply updates the same table. The column updated is "Template" and the value it is updating again comes from a form with a name "Letter_tem", providing the ID is like "value" (whatever value is).

It is very difficult to tell without seeing what is in the function/class.
 

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
The symbol "->" tells you that it is returning a value from a class or function.
Close, nothing is necessarily returned. Its the equivalent of a "dot" operator in other Object Oriented langauges. So it is used to return a value or run a method. In this case it's running a subroutine to insert/update the table.

As for the querys, the first one inserts a record with a value from a form (New_template) into a table defined by the variable $tem_table.

The second query simply updates the same table. The column updated is "Template" and the value it is updating again comes from a form with a name "Letter_tem", providing the ID is like "value" (whatever value is).

Right. The first one inserts your template from the form as a record into the 'Template' field of your table. The second updates an existing template in the table.

It might be better to include a link to your form and tell us what you want to happen.
 

xcaliberse

New Member
Messages
46
Reaction score
0
Points
0
Seems like a PHP/ MySQL script. I think what u need for this to happen is a HTML post code.
 

balaji2u

New Member
Messages
410
Reaction score
2
Points
0
Close, nothing is necessarily returned. Its the equivalent of a "dot" operator in other Object Oriented langauges. So it is used to return a value or run a method. In this case it's running a subroutine to insert/update the table.

Right. The first one inserts your template from the form as a record into the 'Template' field of your table. The second updates an existing template in the table.

It might be better to include a link to your form and tell us what you want to happen.

I want to have a text field that shows text like

Hi my name is {name} ,im living in {place}.i finished masters in {degree}.Im now going to {destination}.

and now below this text box there are 4 drop down boxes one is {name} ,and for {place} and for {degree} and for {destination}
all these drop down boxes have multiple values for example
{name} list box contains options like vol7ron,corey,jackson etc
now if he selects the name vol7ron then the next page(i.e page that comes after clicking submit button) must show the replaced texts and now it will become a easily made document.
hope this is sufficient if you want to know more details pls dont hesitate to ask me.
 

exghost

New Member
Messages
1
Reaction score
0
Points
0
you can use cookies to store data...and it will appear in the next page too..

<?php
session_start();
setcookie ( 'name', 'vol7ron', time() + 1209600 );
?>

and on the next page you can get it by using $_COOKIE['name'] like this

<?php
session_start();
echo "Hi my name is".$_COOKIE['name'].", im living....";
?>
 
Last edited:

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
you don't need `session_start()` to use cookies. session_start is only if you are going to be using `$_SESSION`'s instead. you would set sessions like `$_SESSION['name'] = 'vol7ron';`. there's no expiration time since they expire when you close your browser.
 

gptsven

New Member
Messages
253
Reaction score
5
Points
0
you don't need `session_start()` to use cookies. session_start is only if you are going to be using `$_SESSION`'s instead. you would set sessions like `$_SESSION['name'] = 'vol7ron';`. there's no expiration time since they expire when you close your browser.

you do need sessions when using cookies to automatically login a user -.-
 

gptsven

New Member
Messages
253
Reaction score
5
Points
0
You are the one who is ignorant.

cookies are mainly used to auto-login users on forums/websites.

and Im saying
you need a session to log in, using the data from your cookie (autologin)

"mister I argument everything and im always right"
whats your argument for this line?

I HATE IT WHEN ILL-INFORMED PEOPLE TELL ME I'M WRONG WHEN OBVIOUSLY THEY HAVE LESS EXPERIENCE WITH PHP THEN I, AND CONSIDERING THE FACT THAT I BACKUP MY STATEMENTS WITH WELL RESPECTED SOURCES!!!

firstly I'm not ILL-formed
secondly,I didnt tell you you are wrong you idiot I only stated that you DO need sessions if you want users to be able to login automatically, dumb****, learn to read.

Its nice to include a lot of arguments and sources in your post. for those who are still learning. I however do not need to learn anything anymore PHP-wise. I'm not saying I know everything, but I know how to use php.net to find and implement the functions I need. you did not enlighten me with your post. I know what sessions are, I know what cookies are. I KNOW OK? I'm not some retarded kid who just started doing php and is trying to bash you ok?


so my advice for you is
stay calm, and dont feel offended. cause that was never my intention.
I really hope your reply on this post is going to be somewhat less childish
 
Last edited:

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
balaji2u,

I'm just checking back now that it's after hours in my office. I'm not sure what's going on above, but there are several ways to accomplish what you're trying to do. They include:

1) Cookies (as mentioned above)
2) QueryString (recommended)
3) Database/FileSystem Interaction (recommended if storing the data)

Cookies are not necessarily needed here if you're trying to use a form to compose a document. The truth is this can all be done dynamically on the same page in Javascript using either input boxes, or changing the innerHTML of elements.

If you're trying to store the user information for safe keeping, then you'll need something like the script in your original post. They store/update data in your database, all you need is a SELECT query to retrieve it.

If the data is not something you want to save and there's not a lot of it, just use the QueryString. That is, your URL will be something like http://www.domainlagoon.com/assuran...ol7ron&place=DC&degree=BS&destination=so rich
You can achieve this by setting your form's method to get (ie <form method="get"></form>)

Then when you get to the next page, you'd parse the QueryString and be able to retrieve everything and fill it in the document you're making. However, if a user doesn't need to log in or anything, you can just prepare this document dynamically on the same page and not even use a submit button, or a form that goes to another page - again, this is achieved by using the DOM object's innerHTML property.
 
Last edited:
Top