User-defined tag question

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
badfrog@w00tz!

User-defined tag question

Post by badfrog@w00tz! »

Hey guys, I'm running cmsms 0.13, php 4.3.11, mysql 4.0.27-standard and Apache 1.3.34 (Unix), and I'm trying to implement a quickie one-off registration system for a special event.

I already have a form defined in a content page that accepts the info I need, I'm working on the post target page, which is the basic "read things out of _POST and execute an INSERT statement against a table" type of thing. I am trying to do this as a content page containing a single UDT, which in turn contains my post-processing code, which, for the sake of completeness, looks like this:

Code: Select all

if( count($_POST) != 0 && isset($_POST["submit"]))
	{
		$real_name = mysql_real_escape_string($_POST["real_name"]);
		$gamer_name = mysql_real_escape_string($_POST["gamer_name"]);
		$email = mysql_real_escape_string($_POST["email"]);
		$age = mysql_real_escape_string($_POST["age"]);
		$birth_month = mysql_real_escape_string($_POST["birth_month"]);
		$birth_day = mysql_real_escape_string($_POST["birth_day"]);
		$preferred_tryout = mysql_real_escape_string($_POST["preferred_tryout"]);
		
		$query = "INSERT INTO cs_tryouts VALUES ('$real_name', '$gamer_name', '$email', $age, $birth_month, $birth_day, '$preferred_tryout')";
		
		$linkid = @mysql_connect("localhost", "[CENSORED]", "[CENSORED]");
		or die("Could not open MySQL on localhost");
		@mysql_select_db("w00tz_tryouts") or die("Count not open database w00tz_tryouts");
		$result = mysql_query($query);
		if($result)
		{
			echo( "Thanks for registering, $gamer_name. We will contact you via e-mail shortly with a definite tryout date. If you have any questions regarding your registration, please feel free to contact w00tz! directly.");
		}
		else
		{
			echo("There was a problem processing your registration. Please try again later.");
		}
		@mysql_close();
		exit;
	}
	else
	{
		echo("You have reached this page in error. [<a href='index.php'>Return to w00tz!</a>]");
	}

When I try to save this code as a UDT, I get an "Invalid code entered." error message. The docs I've looked at are sketchy on this, if they mention it at all. Is this error because of the tag I'm echoing out, or is this a parse error in the script itself?
badfrog@w00tz!

Re: User-defined tag question

Post by badfrog@w00tz! »

I just tried doing an include in the tag, but the included file is echoed straight to the client, php isn't parsing the file contents. Wrapping the code inside a tag doesn't help either.


HELP! ???
badfrog@w00tz!

Re: User-defined tag question

Post by badfrog@w00tz! »

Is it even possible to do what I'm trying to do? I am not able to use a URL of the format index.php?page=registration_complete as a post target.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: User-defined tag question

Post by Ted »

Take out the exit for one.  I'm not sure if that's going to help or not, though.

Unfortunately, with the parsing code that php provides to eval functions on the fly, it doesn't tell us what's wrong with the code, only that it's invalid.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: User-defined tag question

Post by Ted »

Very interesting.  Apparently someone recently posted a way to get the parser error from the code, even though it's pretty convoluted.

Just a note to myself so I can remember to put it in later: http://us2.php.net/manual/en/function.eval.php#66631

Anyway, I pasted the code in myself and yes, it's not working.  I don't really see anything wrong...
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: User-defined tag question

Post by Ted »

Found it.  An extra ;

Code: Select all

$linkid = @mysql_connect("localhost", "[CENSORED]", "[CENSORED]");
or die("Could not open MySQL on localhost");
should be

Code: Select all

$linkid = @mysql_connect("localhost", "[CENSORED]", "[CENSORED]")
or die("Could not open MySQL on localhost");
And it was a good test for the code I just added to give me a proper error message...
badfrog@w00tz!

Re: User-defined tag question

Post by badfrog@w00tz! »

Ted wrote: Found it.  An extra ;
Thanks Ted, I found that independantly. I'm not able to use a cmsms url as a post target though, I get a 404 error when I try... any ideas?

Also, I'm trying to put the HTML form itself in as a user defined tag, and I'm getting the same Invalid code error:

Code: Select all

<div class="boxContainer"> 		<span style="left: 5px;" class="insetDecoration"> </span> 		<span style="left: 2px;" class="insetDecoration"> </span> 		 
<div class="box">
<h2 class="boxTitle">:. Register</h2>
<div class="boxContent">
<form action="processRegistration.php" method="post" name="tryoutRegistrationForm" id="tryoutRegistrationForm">
   
    <center>
    <table width="75%">
        <tbody>
            <tr>
                <td width="20%">            Real Name(*)         </td>
                <td align="left"><input type="text" maxlength="50" size="50" value="" name="real_name" /> </td>
            </tr>
            <tr>
                <td>            Alias/Tag(*)         </td>
                <td align="left"><input type="text" maxlength="50" size="50" value="" name="gamer_name" /> </td>
            </tr>
            <tr>
                <td>            E-mail (*)         </td>
                <td align="left"><input type="text" maxlength="100" size="50" value="" name="email" /> </td>
            </tr>
            <tr>
                <td>            Verify E-mail (*)         </td>
                <td align="left"><input type="text" maxlength="100" size="50" value="" name="email_again" /> </td>
            </tr>
            <tr valign="top">
                <td>            Age(*)         </td>
                <td align="left"><input type="text" maxlength="50" size="50" name="age" />
                <div class="address"> NOTE: Gamers under 17 will be required to submit a parental consent form due to the game's M (17+) ESRB rating. </div>
                </td>
            </tr>
            <tr>
                <td>            Birth Month(*)         </td>
                <td align="left"><select name="birth_month">
                <option value="1">January</option>
                <option value="2">February</option>
                <option value="3">March</option>
                <option value="4">April</option>
                <option value="5">May</option>
                <option value="6">June</option>
                <option value="7">July</option>
                <option value="8">August</option>
                <option value="9">September</option>
                <option value="10">October</option>
                <option value="11">November</option>
                <option value="12">December</option>
                </select>  </td>
            </tr>
            <tr>
                <td>            Birth Day*         </td>
                <td align="left"><select name="birth_day">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
                <option value="7">7</option>
                <option value="8">8</option>
                <option value="9">9</option>
                <option value="10">10</option>
                <option value="11">11</option>
                <option value="12">12</option>
                <option value="13">13</option>
                <option value="14">14</option>
                <option value="15">15</option>
                <option value="16">16</option>
                <option value="17">17</option>
                <option value="18">18</option>
                <option value="19">19</option>
                <option value="20">20</option>
                <option value="21">21</option>
                <option value="22">22</option>
                <option value="23">23</option>
                <option value="24">24</option>
                <option value="25">25</option>
                <option value="26">26</option>
                <option value="27">27</option>
                <option value="28">28</option>
                <option value="29">29</option>
                <option value="30">30</option>
                <option value="31">31</option>
                </select>  </td>
            </tr>
            <tr valign="top">
                <td>            Preferred Date:*         </td>
                <td align="left"><select name="preferred_tryout">
                <option value="6/23(Friday)">6/23(Friday)</option>
                <option value="6/24(Satuday)">6/24(Saturday)</option>
                <option value="6/25(Sunday)">6/25(Sunday)</option>
                </select>
                <div class="address"> NOTE: We will make every effort to accomodate requested dates for a tryout, but we cannot guarantee that you will be scheduled on the date you requested. </div>
                </td>
            </tr>
            <tr valign="top">
                <td>            Home zip code:*         </td>
                <td align="left"><input type="text" id="home_zip" name="home_zip" />
                <div class="address"> NOTE: We are currently limiting tryouts to gamers who reside in the Louisville area due to regular practice requirements. </div>
                </td>
            </tr>
        </tbody>
    </table>
    </center> <br />  <input type="submit" value="Submit" name="submit" /> <input type="submit" value="Cancel" name="cancel" /> <br />
</form>
</div>
</div>
</div>
Locked

Return to “CMSMS Core”