Well, it was my understanding from reading the various policies and FAQs that the
admin sorta frowned on that, I think it says something about that, in one of
those guidelines. But if you think it will help, I guess the page isn't too long.
First off, though, couple of things, and a question. (it would be just plain lazy of
me to simply dump this problem here and expect someone to solve it for me,
plus I wouldn't learn much, if I don't make the effort to try and solve it myself,
hopefully with some help from some of you folks that know a lot more php than
I do).
1) I resolved the email problem; it wasn't the script, but a hairball with my host;
fixed now (checked both with a test msg from a diff domain, and from a test-
submission using a clean-unmodified process.php -- the email does now get
sent and received).
2) After fixing it back to the clean-unmodified version, I tried it again with my
addition, but this time making those url variables global. Still doesn't work,
with or without the global. (perhaps I should clarify, it works precisely as the
unmodified process.php works -- it writes to the db and does the email, but still
with the original value of $SetDesired, so my addition is the part not working).
And finally my question, probably a very stupid question but since I know so little of
how variables are handled, I must ask it, simply for my own clarification.
In the bits
if ($SetDesired == "Set 01") {
$SetDesired == $set01url;
}
Since the '$set01url' is referring to a string (the actual url), should it have quotes
around it, even though it's a variable?
And also: is there some better way of getting the new string into the $SetDesired
variable, than those '==' operators? The only other programming I ever learned
anything about (and that wasn't much!) was Basic, and this sort of thing would
work, but of course this is very far from Basic of any flavor.
Ok that's it for my input at this point; I'm still stymied, can't figure out why I can't get
those urls into the $SetDesired variable. So here goes with the long-winded php.
This is the original, unmodified process.php, which works perfectly in all respects:
<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','Username');
pt_register('POST','Email');
pt_register('POST','MainURL');
pt_register('POST','SetDesired');
pt_register('POST','Password');
pt_register('POST','AgreeTerms');
if($Username=="" || $Email=="" || $MainURL=="" || $SetDesired=="" || $Password=="" || $AgreeTerms=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Username: ".$Username."
Email: ".$Email."
MainURL: ".$MainURL."
SetDesired: ".$SetDesired."
Password: ".$Password."
AgreeTerms: ".$AgreeTerms."
";
$message = stripslashes($message);
mail("address@mydomain.net","Form Submitted at your website",$message,"From: phpFormGenerator");
$link = mysql_connect("localhost","dbuser","password");
mysql_select_db("freecontentusers",$link);
$query="insert into contentusers (Username,Email,MainURL,SetDesired,Password,AgreeTerms) values ('".$Username."','".$Email."','".$MainURL."','".$SetDesired."','".$Password."','".$AgreeTerms."')";
mysql_query($query);
$make=fopen("admin/data.dat","a");
$to_put="";
$to_put .= $Username."|".$Email."|".$MainURL."|".$SetDesired."|".$Password."|".$AgreeTerms."
";
fwrite($make,$to_put);
header("Refresh: 0;url=http://www.mydomain.net/redirectthanks.html");
}
?>
Here it is with my changes; I've left out the globals thing since you said I didn't
need it, and it didn't work any better with it -- notice that I also changed the final
bit, for set04url, since that was the line causing a parse error when I initially
tried it:
<?php
include("global.inc.php");
$set01url = "http://www.actualurl/of1st/zipfile.zip";
$set02url = "http://www.actualurl/of2nd/zipfile.zip";
$set03url = "http://www.actualurl/of3rd/zipfile.zip";
$set04url = "http://www.actualurl/of4th/zipfile.zip";
if ($SetDesired == "Set 01") {
$SetDesired == $set01url;
}
elseif ($SetDesired == "Set 02") {
$SetDesired == $set02url;
}
elseif ($SetDesired == "Set 03") {
$SetDesired == $set03url;
}
else {
$SetDesired == $set04url;
}
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','Username');
pt_register('POST','Email');
pt_register('POST','MainURL');
pt_register('POST','SetDesired');
pt_register('POST','Password');
pt_register('POST','AgreeTerms');
if($Username=="" || $Email=="" || $MainURL=="" || $SetDesired=="" || $Password=="" || $AgreeTerms=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Username: ".$Username."
Email: ".$Email."
MainURL: ".$MainURL."
SetDesired: ".$SetDesired."
Password: ".$Password."
AgreeTerms: ".$AgreeTerms."
";
$message = stripslashes($message);
mail("address@mydomain.net","Form Submitted at your website",$message,"From: phpFormGenerator");
$link = mysql_connect("localhost","dbuser","password");
mysql_select_db("freecontentusers",$link);
$query="insert into contentusers (Username,Email,MainURL,SetDesired,Password,AgreeTerms) values ('".$Username."','".$Email."','".$MainURL."','".$SetDesired."','".$Password."','".$AgreeTerms."')";
mysql_query($query);
$make=fopen("admin/data.dat","a");
$to_put="";
$to_put .= $Username."|".$Email."|".$MainURL."|".$SetDesired."|".$Password."|".$AgreeTerms."
";
fwrite($make,$to_put);
header("Refresh: 0;url=http://www.mydomain.net/redirectthanks.html");
}
?>
That's it. I'm going to keep reading and bashing away at it, but really I'm totally
perplexed at this point, so I hope you can make something more of it than I can.
Oh and one other question: would it be helpful to see that global.inc.php
that's included at the top of process.php? And (just for the heck of asking) do
you think it might work better if I included my additions there, instead of in
process.php? (that way, process.php would never see the original value of
$SetDesired)
Thx very much!
Carmi