TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,911
  • Total Topics: 21,307
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 697
  • Total: 697

[Done!] Join Us! form

Started by mebymyself, October 19, 2006, 08:10:13 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

JPDeni

I think I can simplify things a bit. First, delete the taken.php file.

Change

echo '" /></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Car/Truck Number: Please make sure it is available</TD>
<TD><INPUT id="number" name="number" type="text" value ="';
include '/numbers/taken.php';
if (isset($_POST['number'])) echo $_POST['number'];   
echo '" /></TD>


to


echo '" /></TD></TR>
        <TR class ="windowbg">
          <TD width = "200px">Car/Truck Number: Please make sure it is available</TD>
          <TD><INPUT id="number" name="number" type="text" value ="';
if (isset($_POST['number'])) echo $_POST['number']; 
echo '">';
$result = db_query("SELECT *
                    FROM taken
                    ORDER BY number", __FILE__, __LINE__);
while ($column = mysql_fetch_array($result))
  $taken[] = $column['number'];
$numbers = implode(", ",$taken);
echo $numbers;
echo '</TD>


I think your major problem was that you were having the "taken" numbers printed out within the input field. Also, you didn't need to create an entire page. But it's just as easy to put it into the article itself so that if you need to edit it, it's right there for you to work on, rather than having a separate file.

You can add whatvever formatting you want to the numbers. Just be sure that you put it in single quotes. Something like


echo '<font color="#000000">' . $numbers . '</font>';


Since at the time of printout, all of the numbers are in one variable, with commas and spaces between them, you can also add text to it, such as


echo '<font color="#000000">Numbers taken - ' . $numbers . '</font>';


Of course, I haven't tested this, but I'm pretty sure I've got all the semi-colons where they need to go. :)

Chevy21

Hi all,

Ok I am liking this script more and more and using it for various things.  I do have one question that I am trying to do.

I am trying to get in the forum topic that is started in the subject line from the form.  The information I am trying to get on the subject line is from some of the actual stuff in the form.  I have tried removing the ['user']['name'] and adding the field id names from the form and that doesn't work.

Report has been filed for "Series", "Date", Track" instead of the original [Pending] Application of [Membername]

I know the info being posted is from this section:
//create new forum post with application

$msgOptions = array(
'id' =>  0 ,
'subject' => '[Pending] Application of ' . $context['user']['name'],
'body' => $postbody ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' =>  array(),
);
$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' =>  null,
'lock_mode' =>  null,
'sticky_mode' =>  null,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => $context['user']['id'],
'name' => $context['user']['name'],
'email' => $user_info['email'],
'update_post_count' => true,
);


Any help on this would be greatly appreciated.

Thanks in advance.

JPDeni

QuoteI have tried removing the ['user']['name'] and adding the field id names from the form and that doesn't work.

What exactly did you do? Give us the code you used and exactly what you want to accomplish. Details, details, details!!! :)

Chevy21

Quote from: JPDeni on June 01, 2008, 05:19:52 PM
QuoteI have tried removing the ['user']['name'] and adding the field id names from the form and that doesn't work.

What exactly did you do? Give us the code you used and exactly what you want to accomplish. Details, details, details!!! :)


Hi JPDeni,

Thanks for the reply

Here is the code I tried to use that will not work for some reason.
//create new forum post with application

$msgOptions = array(
'id' =>  0 ,
'subject' => 'Post Race Inspection Report for  ' . $context['series']['date']['track'],
'body' => $postbody ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' =>  array(),
);
$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' =>  null,
'lock_mode' =>  null,
'sticky_mode' =>  null,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => $context['user']['id'],
'name' => $context['user']['name'],
'email' => $user_info['email'],
'update_post_count' => true,


Under the $msgOptions = array(  is what I was trying to modify.  I don't need the username who filed the report listed in the subject line of the forum topic, just the info I listed in my original post above your reply.

Hope this helps

JPDeni

Where did you get the value for


$context['series']['date']['track'],


What does "doesn't work" mean? Do you get nothing? Do you get an error message? Is there an error in your error log? What happens?

Chevy21

The $context['series']['date']['track'] are fields that I am currently using in the form to have a person input value for.

As far as it not working, it only shows "'Post Race Inspection Report for  " which I am wanting it to show EXAMPLE - "'Post Race Inspection Report for Pro Series, Milwaukee, 05/15/08" in the subject line once form has been submitted.  All other information in the body of the topic and email sent shows up properly.

Here is my entire script that I am using.

if ($context['user']['is_guest'])
{
   echo
   '<h5>Access Denied</h5>
   We are sorry. You must be registred on the site in order to apply for  Clan membership.';
} else  {


global $sourcedir, $user_info, $context ;

require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');

//send the application by email?
$enable_email=true;

// email address of reqruitment staf member
$email_address='admin@cs-racin.com';

//post the application on forum?
$enable_post=true;

//board id to which the application should be posted
$board_id=33.0;

//the id of the this article
$this_article_id = '15';

//article to be redirected when form is submitted
$thank_you_article_id = '6';


//END OF CONFIGURATION SECTION



$show_form= 'true';
if (isset($_POST['submitted'])) {
// Handle the form

// Check required fields
$enroll_errors = array(); //Initialize error array

// Check for a series
if (empty($_POST['series']) ){
$enroll_errors[] = 'You forgot to enter a series.';
}
// Check for an date
if (empty($_POST['date']) ){
$enroll_errors[] = 'You forgot to enter your a Race Date.';
}   
// Check for an Track
if (empty($_POST['track']) ){
$enroll_errors[] = 'You forgot to enter a Track.';
}
// Check for an Length
if (empty($_POST['length']) ){
$enroll_errors[] = 'You forgot to enter Race Length.';
}

if (empty($enroll_errors)) { //Everything seems to be OK
     
        $show_form='false';



// email a Report

$subject = 'Post Race Inspection Report';
$body = 'Post Race Inspection Report has been made by ' . $context['user']['name'] .
' from IP Address ' . $user_info['ip'] . '
Series:  ' . $_POST['series'] . '
Race Date:  ' . $_POST['date'] . '
Track:  ' . $_POST['track'] . '
Race Length: ' . $_POST['length'] . '
Drivers Checked:  ' . $_POST['checked'] . '
Drivers who Failed Inspection:  ' . $_POST['failed'] . '
Cheats Used:  ' . $_POST['cheat'] ;


$postbody = 'Post Race Inspection Report has been made by ' . $context['user']['name'] .'
[table]
[tr][td]Series:[/td][td]  ' . $_POST['series'] . '[/td][/tr]
[tr][td]Race Date:[/td][td]  ' . $_POST['date'] . '[/td][/tr]
[tr][td]Track:[/td][td]  ' . $_POST['track'] . '[/td][/tr]
[tr][td]Race Length: [/td][td]' . $_POST['length'] . '[/td][/tr]
[tr][td]Drivers Checked:[/td][td]  ' . $_POST['checked'] . '[/td][/tr]
[tr][td]Drivers who failed Inspection:[/td][td]  ' . $_POST['failed'] . '[/td][/tr]
[tr][td]Cheats Used:[/td][td]  ' . $_POST['cheat'] . '[/td][/tr]
[/table]';


            if ($enable_email)
mail($email_address, $subject, $body,"From: " . $_POST['email']);



//create new forum post with application

$msgOptions = array(
'id' =>  0 ,
'subject' => 'Post Race Inspection Report for  ' . $context['series']['date']['track'],
'body' => $postbody ,
'icon' => 'xx',
'smileys_enabled' => true,
'attachments' =>  array(),
);
$topicOptions = array(
'id' => 0 ,
'board' => $board_id,
'poll' =>  null,
'lock_mode' =>  null,
'sticky_mode' =>  null,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => $context['user']['id'],
'name' => $context['user']['name'],
'email' => $user_info['email'],
'update_post_count' => true,
);
   
if ($enable_post)
            createPost($msgOptions, $topicOptions, $posterOptions);

// Redirect to thank you page
header('Location: http://' . $_SERVER['HTTP_HOST'] .'/index.php?page=' . $thank_you_article_id);

} else {
// Redirect to error page
//header('Location: http://' . $_SERVER['HTTP_HOST'] . '/index.php?page=' . $enroll_error_article_id );
echo '<h2 class="error">Error!</h2>';
echo '<p class="error">The following error(s) occured:<br />';

foreach ($enroll_errors as $msg) {
echo " - $msg<br />";
}
   echo "<p>Please, correct all errors and try again.</p>" ;



}
}
//else { // Display the form
echo'
<p align="center"><b><font face="Comic Sans MS" size="5" color="#FF0000">Post
Race Inspection Report</font></b></p>
<p align="center"> </p>
<p align="center"><b><font face="Comic Sans MS" color="#FF0000">Please make sure
you fill this out with all required information.</font></b></p>
<p align="center"><b><font face="Comic Sans MS" color="#FF0000">All cheats that
are shown, please copy/paste the actual cheat information in the Cheats Used
block.  If multiple drivers are found to be cheating please break each
driver down and the cheat used in the given format in the Post Race Inspection
Forum Area.</font></b></p>
<p align="center"><font face="Comic Sans MS" color="#00FFFF">Thank you for your
assistance in making this league a Cheat Free League.<br>
</font>
</p>

';
echo '
<form action="index.php?page='  . $this_article_id  . '" method="post">
        <INPUT id="submitted" name="submitted" type="hidden" value="TRUE" />
<TABLE class = "bordercolor" cellSpacing="1" cellPadding="1" width="95%" border="0">
<TR class ="windowbg">
<TD width = "200px">Series Checked:</TD>
<TD><INPUT id="series" name="series" type="text" value ="';
if (isset($_POST['series'])) echo $_POST['series'];
echo '" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Date of Race:</TD>
<TD><INPUT id="date" name="date" type="text" value ="';
if (isset($_POST['date'])) echo $_POST['date']; else echo $user_info['date']; 
echo '" /></TD>
</TR>
<TR class ="windowbg2">
<TD width = "200px">Track:</TD>
<TD><INPUT id="track" name="track" type="text" value ="';
if (isset($_POST['track'])) echo $_POST['track'];   
echo '" /></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Race Length:</TD>
<TD><INPUT id="length" name="length" type="text" value ="';
if (isset($_POST['length'])) echo $_POST['length'];   
echo '" /></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">Drivers Checked</TD>
<TD><INPUT id="checked" name="checked" type="text" value ="';
if (isset($_POST['checked'])) echo $_POST['checked'];
echo '" /></TD></TR>
<TR class ="windowbg2">
<TD width = "200px">List Drivers who Failed Post Race Inspection</TD>
<TD><TEXTAREA id="failed" name ="failed" rows="4" cols="40" value ="';
if (isset($_POST['failed'])) echo $_POST['failed'];   
echo '" ></' . 'TEXTAREA></TD>
</TR>
<TR class ="windowbg">
<TD width = "200px">List and copy/paste Cheats used for each Driver</TD>
<TD><TEXTAREA id="cheat" name ="cheat" rows="4" cols="50" value ="';
if (isset($_POST['cheat'])) echo $_POST['cheat'];   
echo '" ></' . 'TEXTAREA></TD>
</TR>
<TR class ="windowbg2">
<TD colspan="2" align="center">
<p align="center"><font color="#FF0000"><b>By submitting this Post Race Inspection Report, you agree that all information provided is true to the best of your knowledge.</b></font></p>
<INPUT type="submit" value="Submit">
<INPUT type="reset" value="Reset"></TD>
</TR>
</TABLE>
</form>

';
}

JPDeni

I see. The $context array is defined elsewhere in SMF, and not in the form script. What you need to use is the $_POST array.

After


$postbody = 'Post Race Inspection Report has been made by ' . $context['user']['name'] .'
[table]
[tr][td]Series:[/td][td]  ' . $_POST['series'] . '[/td][/tr]
[tr][td]Race Date:[/td][td]  ' . $_POST['date'] . '[/td][/tr]
[tr][td]Track:[/td][td]  ' . $_POST['track'] . '[/td][/tr]
[tr][td]Race Length: [/td][td]' . $_POST['length'] . '[/td][/tr]
[tr][td]Drivers Checked:[/td][td]  ' . $_POST['checked'] . '[/td][/tr]
[tr][td]Drivers who failed Inspection:[/td][td]  ' . $_POST['failed'] . '[/td][/tr]
[tr][td]Cheats Used:[/td][td]  ' . $_POST['cheat'] . '[/td][/tr]
[/table]';


add


$subject = "Post Race Inspection Report for ' . $_POST['series'] . ' ' . $_POST['track'] . ' ' . $_POST['date'];


Change

'subject' => 'Post Race Inspection Report for  ' . $context['series']['date']['track'],


to


'subject' => $subject,

Chevy21

Ok got the following error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/mysite/public_html/Sources/Load.php(1789) : eval()'d code(246) : eval()'d code on line 91

Line 91 is
$subject = "Post Race Inspection Report for ' . $_POST['series'] . ' ' . $_POST['track'] . ' ' . $_POST['date'];

JPDeni

Sorry. Got my quotation marks mixed up.


$subject = 'Post Race Inspection Report for ' . $_POST['series'] . ' ' . $_POST['track'] . ' ' . $_POST['date'];

Chevy21

AWESOME as always you come through.  THANK YOU very much for your help it is Greatly Appreciated. :up:   ;)


This website is proudly hosted on Crocweb Cloud Website Hosting.