FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


I don't know how to describe it but I need help.





cr3ativ3
Ok, I am not big on PHP terminology so I don't really know how to describe it but I will try my best to show you what I am doing and what I am having trouble with it.

Let's start by showing you the two scripts involved in this:


back.php

Code:

<?php
$from = $_POST['from'];
switch ($from) {
case '':
   echo "<META HTTP-EQUIV=\"Refresh\"
      CONTENT=\"0; URL=index.php?action=link&what=feed.php&action=verifyemail&what=\">";
   exit;
   case ' ':
      echo "<META HTTP-EQUIV=\"Refresh\"
      CONTENT=\"0; URL=index.php?action=link&what=feed.php&action=verifyemail&what=\">";
   exit;
   
}
$info = $_POST['info'];
switch ($info) {
case '':
   echo "<META HTTP-EQUIV=\"Refresh\"
      CONTENT=\"0; URL=index.php?action=link&what=feed.php&action=verifytext&what=\">";
   exit;
   case ' ':
      echo "<META HTTP-EQUIV=\"Refresh\"
      CONTENT=\"0; URL=index.php?action=link&what=feed.php&action=verifytext&what=\">";
   exit;
   
}
$name = $_POST['name'];
$subject = $_POST['subject'];

$to      = "";
$subject = "$subject [Contact Us Form]";
$message = "$info

---------------
This Message Was Sent By The Online Feed Back Form
---------------";
$headers = "From: $name [$from]" . "\r\n" .
   "Reply-To: $from" . "\r\n";

mail($to, $subject, $message, $headers);
if (@mail($to, $subject, $message, headers)) {
 echo("<META HTTP-EQUIV=\"Refresh\"
      CONTENT=\"0; URL=index.php?action=link&what=feed.php&action=complete&what=\">");
} else {
 echo('<p>Mail could not be sent.</p>');

?>



feed.php
Code:

<table width="95%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="18" height="31" background="UserFiles/corner1.PNG"></td>
    <td background="UserFiles/top.PNG" align="center"><font face="Arial, Helvetica, sans-serif"><b><!--Title-->Email Us</b></font></td>
    <td width="18" height="31" background="UserFiles/corner2.PNG"></td>
  </tr>
  <tr>
    <td background="UserFiles/side1.PNG"></td>
    <td align="center" valign="center"><font face="Arial, Helvetica, sans-serif"><!--Content-->
<div align="center">Please fill out the form below with your comments/questions and we will recieve them by email and try to respond shortly.<br /><br><font size="-3"><font color="red">*</font>Required Fields</font><br /><br /><?php
   
if (isset($_GET['action'])) {
  switch (strtolower($_GET['action'])) {
    case 'complete' : do_complete(@$_GET['what']); break;
    default : break;
   }
}

function do_complete() {
Echo "<br><font color=\"red\">Succesfully You should recieve a response within 48 hours if you don't, feel free to resend your questions/comments or call us.</font>";
};
 ?></div>
<form action="back.php" method="post">

<table width="100%" border="0" cellspacing="0" cellpadding="5" align="center">
  <tr>
     <td align="right" valign="top"><font face="Arial, Helvetica, sans-serif">Name:</font></td>
   <td align="left" valign="top"><input name="name" type="text" /></td>
  </tr>
  <tr>
    <td align="right" valign="top"><font face="Arial, Helvetica, sans-serif"><font color="red">*</font>Your Email Address:</font></td>
    <td align="left" valign="top"><input name="from" type="text" /><?php
   
if (isset($_GET['action'])) {
  switch (strtolower($_GET['action'])) {
    case 'verifyemail' : do_verifyemail(@$_GET['what']); break;
    default : break;
   }
}

function do_verifyemail() {
Echo "<br><font color=\"red\">Email Address Is Wrong</font>";
};
 ?></td>
  <tr>
     <td align="right" valign="top"><font face="Arial, Helvetica, sans-serif">Subject:</font></td>
   <td align="left" valign="top"><input name="subject" type="text" /></td>
  </tr>
  </tr>
  <tr>
    <td align="right" valign="top"><font face="Arial, Helvetica, sans-serif"><font color="red">*</font>Questions/Comments:</font></td>
    <td align="left" valign="top"><textarea name="info" cols="25" rows="7"></textarea>
   <?php
   
if (isset($_GET['action'])) {
  switch (strtolower($_GET['action'])) {
    case 'verifytext' : do_verifytext(@$_GET['what']); break;
    default : break;
   }
}

function do_verifytext() {
Echo "<br><font color=\"red\">^Oops it appears that you havn't filled in this part^</font>";
};
 ?>
   </td>
  </tr>
</table>
<div align="center"><input name="" type="submit" value="Submit" /></div>
</form>
</font></td>
    <td background="UserFiles/side2.PNG"></td>
  </tr>
  <tr>
    <td width="17" height="17" background="UserFiles/corner3.PNG"></td>
    <td background="UserFiles/bottom.PNG"></td>
    <td width="17" height="17" background="UserFiles/corner4.PNG"></td>
  </tr>
</table><br />


Ok, and there are a few urls that are used in this script:

Quote:
index.php?action=link&what=feed.php

(The form page where you fill out the form)
Quote:
index.php?action=link&what=feed.php&action=verifyemail&what=

(If the email is wrong this will activate the wrong email message)
Quote:
index.php?action=link&what=feed.php&action=verifytext&what=

(If the comments/questions are not filled out this will activate the error message)
Quote:
index.php?action=link&what=feed.php&action=complete&what=

(If the email was successfully sent this will activate the succesfully sent message.

The problem I am having here is getting these urls: "index.php?action=link&what=feed.php&action=complete&what=" to work one of those urls is loading a page onto the page in this case feed.php and then the seconds part is activating one of the php sections of the page to alert the user they filled something in wrong. If you look through the scripts you will see what I meen.

Now you might be saying now that its the index.php should be feed.php but no I am loading the feed.php into index.php so that is not the problem I guess the real problem is getting two of "action=complete&what=" these things in one url to work. To see an example of what I am talking about visit: http://www.oyoystudios.frih.net/Saunders/index.php?action=link&what=feed.php

I hope you can help =)
hexkid
cr3ativ3 wrote:
Quote:
index.php?action=link&what=feed.php&action=verifyemail&what=

Why two "what"s?

In my tests PHP only caught the second what.
Code:
<?php
echo $_GET['what'];
?>


When I run that with
Quote:
test.php?what=one&what=
PHP returns an empty document; when I run it with
Quote:
test.php?what=&what=two
PHP returns a document with "two"
cr3ativ3
Sorry, ya I know that is bad code but it still works see what that does is activate this part of feed.php:

Code:

<?php
   
if (isset($_GET['action'])) {
  switch (strtolower($_GET['action'])) {
    case 'complete' : do_complete(@$_GET['what']); break;
    default : break;
   }
}

function do_complete() {
Echo "<br><font color=\"red\">Succesfully You should recieve a response within 48 hours if you don't, feel free to resend your questions/comments or call us.</font>";
};
 ?>


Well this is the url that activates this part I guess you can figure out the rest of the activation sequences: "index.php?action=link&what=feed.php&action=complete&what="
hexkid
cr3ativ3 wrote:

case 'complete' : do_complete(@$_GET['what']); break;



"index.php?action=link&what=feed.php&action=complete&what="


You will do

Code:
do_complete('')


and not

Code:
do_complete('feed.php')
cr3ativ3
Ok, thanks but it still doesn't fix my problem.
hexkid
How do you "load feed.php into index.php"?
cr3ativ3
Oh ok, I wasn't sure if you people needed to know but its a technique I developed I made a tutorial on it in the tutorials sections its what I like to call php frames.

K here:

Code:

<?php
if (isset($_GET['action'])) {
  switch (strtolower($_GET['action'])) {
    case 'link' : do_link(@$_GET['what']); break;
    default : break;
   }
}
?>
<?php
function do_link($link) {
include "$link";
};
?>


and it also involves the link from another page:

Quote:
index.php?action=link&what=feed.php


So this link inputs the variable $link as feed.php and then I include the variable $link which in this url is feed.php which inturn displays feed.php.
hexkid
Sorry for the loss of indentation
cr3ativ3 wrote:
<?php // index.php
if (isset($_GET['action'])) {
switch (strtolower($_GET['action'])) {
case 'link' : do_link(@$_GET['what']); break;
default : break;
}
}
?>
<?php
function do_link($link) {
include "$link";
};
?>
cr3ativ3 wrote:
<?php // feed.php
if (isset($_GET['action'])) {
switch (strtolower($_GET['action'])) {
case 'complete' : do_complete(@$_GET['what']); break;
default : break;
}
}
?>


Unless you change it (and it appears that you don't, as you shouldn't) $_GET['action'] is the same in index.php and in the included file (feed.php).

You need to review how you're going to pass parameters around your files.
cr3ativ3
K any suggestions on what I might do?
hexkid
To avoid messing too much with your code, maybe changing your links to
Quote:
index.php?action=link&what=feed.php&action2=verifytext&what2=

and test for $_GET['action2'] and/or $_GET['what2'] in feed.php, leaving the current tests in index.php as they are.
cr3ativ3
Awsome thanks now that I see it I understand how easy that was to fix lol. I feel so stupid now Smile
Related topics
can i help?
help,Bonding
HELP!!
Help me with MySQL Account Maintenance and phpBB 2.0.15 :((
help, change pass my acc in cpanel
help me upgrade php to 5.
Need help adding a domain
help add admin in phpbb forum
Need Help with Mambo!
help me get this right..
VERY URGENT! Please Help Me!
help getting form info into mysql db
Basic C Programming Help?
need ur help
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.