View Full Version : PHP invisibility
ssskaya
12-25-2002, 05:10 PM
If I want a particular part of the php script to "function", but I want it to be "invisible". what should I do?
Thanks!
raptori
12-25-2002, 05:16 PM
you should explain more.
1. you can include the function part in the script uisng the include('<page>');
2. you cant view the source code of the php when its views in a browser
ssskaya
12-25-2002, 05:29 PM
When I say visible, I mean:
I want to server to use the script, but I do not want the server to take it to the browser.
(It is actually an automatic message kind of thing. So I want this part of the meesage to be sent with the whole message, but Ido not want it to be seen on the browser.)
So:
/* bla bla
*/
is not gonna work for me, because I do not want the server to ignore this part.
I just want it to process it, but not make it visible.
I hope this was clear.
Thanks.
mordred
12-25-2002, 09:14 PM
I'm not sure I understand your request. You want the server to process the script but it shouldn't send any output back to the client? Or do you want the outcome of the script to be saved in a file or another resource and not "printed to the screen"?
ssskaya
12-26-2002, 01:16 AM
Let me be more specific.
I have a php email form.
I want only parts of it to be reflected to the browser.
Say, I want the user to fill in the "name/email/..." box. But the "message box" will be "fixed", and I do not want the user to see it.
In order to achieve that, I still want the message box to be a part of the form, but I do not want it to be screened.
So,.. how can I hide some parts of the php script from the user?
duniyadnd
12-26-2002, 01:51 AM
I'm still not 100% sure what you saying, but as far as I can see, you're not asking for the php script to be hidden, but part of the form to be hidden.
you can do that by changing its type:
<input type="hidden" value="xyz" name="xyz">
or if you want to form to be visible, but the user can't put anything in it, just add disabled
<input type="text" disabled value="xyz" name="xyz">
I figure you saying this, cause I don't believe I can see anyone's php scripts unless I was looking at hte source code before it ran in the browser.
Duniyadnd
ssskaya
12-26-2002, 03:12 AM
Ok, this is the most specificx I can get. :) sorry for the previous confusion.
Below is a part of my email php form.
It consists of 3 parts (Name, email, message) and a submit
button.
What I want to do is hide the "message" part from the screen. And edit it anytime I want, or any way I want.
So,.. the user will se the "name" and the "email" part of the form along with the submit form. They will not see the message text area. (Because I do not want them to write anything to the textarea)
So, how do I modify my script below to be able to hide this particular part of the form from the user?
Thanks!
--------------
echo "<form name=\"form\" method=\"post\" action=\"message.php\">";
echo "<p class=\"bodymd\">Your Name<br><input type=\"text\" name=\"Name\" value=\"$Name\"></p>";
echo "<p class=\"bodymd\">Your Friend's Email<br><input type=\"text\" name=\"Email\" value=\"$Email\"></p>";
echo "<p class=\"bodymd\">Message<br><textarea name=\"Comments\" rows=\"5\" cols=\"20\">Your friend $Name saw our website, and thought that you might be interested. Thanks.</textarea></p>";
echo "<input type=\"submit\" name=\"Send\" value=\"Send\">";
echo "</form>";
Nightfire
12-26-2002, 05:37 AM
If you don't want it shown, then don't add it to the form. Delete the textarea and use
$_POST['Comments'] = 'Your friend '.$Name.' saw our website, and thought that you might be interested. Thanks.';
in the script that adds the info into the email
PHP is serversided so when you submit to (another) PHP page, you will have to load a new page (even if you submit to the same page and use a flag, the browser will still load a new page). You could use frames to load only a part of the screen (reload only one frame) or use client sided scripting (like javascript) to process the info and display the processed info, without making a server connection.
Nightfire
12-27-2002, 11:21 AM
<?
if(!isset($submit)){
?>
<form action="<?=$PHP_SELF?>" method="post">
First name <input type="text" name="Name" value="$Name">
All the rest of the form here....
<input type="submit" name="submit" value="Submit">
</form>
<?
}else{
include("message.php");
}
?>
ssskaya
12-29-2002, 01:53 AM
Nightfire (or sb else):
I solved all the other peoblems.
Here is the last updated script of the table.
The last thing to resolve is:
How do I edit this script in order to make the table operate on its own and NOT to ---> open a new page when someone clicks the submit button.
Thanks!
------
<table border=1 cellspacing=0 cellpadding=0 width=170>
<tr valign="top">
<td colspan="2">
<table><tr><td>
<?php
$to = "fiscalstudy@yahoo.com";
$Comments = "Your friend $Name saw our website, www.FiscalStudy.com , and thought that you might be interested.
Thanks,
FiscalStudy.com Management.";
$ask = 0;
if (($Name == "") && ($Email == ""))
{
$ask = 1;
}
elseif (($Name == ""))
{
$ask = 1;
echo "<p class=\"bodymd\">You missed some field.</p>";
}
if ($ask == 1)
{
echo "<p class=\"bodymd\">Let your friend(s) know about FiscalStudy.com!</p>";
echo "<form name=\"form\" method=\"post\" action=\"message.php\">";
echo "<p class=\"bodymd\">Your Full Name<br><input type=\"text\" name=\"Name\" value=\"$Name\"></p>";
echo "<p class=\"bodymd\">Your Friend's Email<br><input type=\"text\" name=\"Email\" value=\"$Email\"></p>";
echo "<input type=\"submit\" name=\"Submit\" value=\"Send\">";
echo "</form>";
}
else
{
$message = "Name: $Name\nEmail: $Email\nComments: $Comments\n";
$eLog="/tmp/mailError.log";
//Get the size of the error log
//ensure it exists, create it if it doesn't
$fh= fopen($eLog, "a+");
fclose($fh);
$originalsize = filesize($eLog);
if (preg_match('/^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]{2,4}$/', $Email, $matches)) {
print ("Message Sent.</ br></ br>");
mail ($to, "Your friend $Name sent you a message via FiscalStudy.com!", $message, "Cc:$Email");
} else {
print ("Message Sent.</ br></ br>");
mail ($to, "Your friend $Name sent you a message via FiscalStudy.com!", $message);
}
clearstatcache();
$finalsize = filesize($eLog);
//Check if the error log was just updated
if ($originalsize != $finalsize) {
print "<p>There was a problem sending the mail. Please try again later or send the message to<a href=\"$to\">$to</a> using your own mail client program.</p>";
} else {
echo "<p class=bodymd>Thanks for your message, $Name.</p>";
}
}
?>
</td></tr></table>
</td>
</tr>
</table>
Nightfire
12-29-2002, 08:08 AM
It has to reload the page. That is how PHP works - it needs to commincate to the server and it can't do that without sending the page to the server.
To do it without loading the page, you can have the info show in a popup window or an iframe, but that's the best you're gonna get i'm afraid.
ssskaya
12-29-2002, 05:42 PM
but then how does my PHP poll perfectly work within its own table?
mordred
12-29-2002, 10:48 PM
If you really want to know... http://ashleyit.com/rs/
But that involves some knowledge about HTTP client-server communication, at least the basics.
If you don't want to employ remote scripting then your only other choice is to reload the page, as Nightfire has already pointed out. That's the way it is.
ssskaya
12-30-2002, 06:40 AM
Dear Mordred,
That is what I am trying to do.
I want to have the the script above as: message.php
and I want it to interact with my index.php
I do not want to insert it to my index.php page and handle everything from there.
Thanks for the page though!
IndyTim
01-03-2003, 08:35 PM
Yikes!
If I am comprehending the thread, try this approach:
page1.php
contains form with field for user e-mail address and other fields you want to pass to mail
using form "post" pass form fields to page2
On submit control passes to page2.php
page2.php
using php, compose your mail message using values pulled from the posting on page1.php along with fixed parts of the mail message (ie. you stated you wanted the message fixed).
After putting it all together in php, go ahead and mail it off.
using the "include" function, take your user to your index page or wherever. The user will not see the processing of the mail message (page2.php) unless you initiate either a "echo" or "print" etc within php.
Hope this helps get you where you want to go.
IndyTim
brentashley
01-04-2003, 04:29 AM
The easiest method of sending information to the server without forcing a refresh is to use an image object.
function sendMsg( msg ){
var i = new Image();
var d = new Date();
var url = "receiveMessage.php?uniq=" + d.getTime()
+ "&msg=" + escape( msg );
i.src = url;
}
The server side just has to be (assuming globals on):
<?
doSomething( $msg );
?>
If you want to get any information back from the server, all you have to do is have the server side set a cookie, and have the client set a timeout for a second to come back and check for the cookie. That's what my RSLite library does at http://www.ashleyit.com/rslite (http://ashleyit.com/rs/rslite/)
- Brent -
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.