Jump to content

add sql row upon registration


Aaron

Recommended Posts

Hello, my VA is completely charter flights (military VA), what I have is a booking system that updates the schedules where the flightnum is the pid. Instead of manually adding these routes in for every pilot that registers, I want to have it add a row in the schedules during registration that sets the flightnum to the pid and leaves everything else blank. I know the code to add a row, I just don't know where I should put it and in which file. I took a crack at it before March break and it didn't seem to work. Any ideas?

Link to comment
Share on other sites

I put this in the RegistrationData.class.php as the last thing to run when a user submits their registration (bottom of AddUser function) and it doesn't work I'm trying to figure out why. Note: used $sql2 to avoid using variable twice

 
$sql2 = "INSERT INTO ".TABLE_PREFIX."schedules (code, flightnum, deptime, arrtime, daysofweek, price, flighttype, enabled)
   VALUES ('CFC', $pilotid, '00:00', '00:00', '0123456', '0', 'P', '1')";

DB::query($sql2);

Link to comment
Share on other sites

  • Moderators

I put this in the RegistrationData.class.php as the last thing to run when a user submits their registration (bottom of AddUser function) and it doesn't work I'm trying to figure out why. Note: used $sql2 to avoid using variable twice

Try this, with the $sql. in there, it'll still run the query. Remove the code above you used, and put this one in.

$sql .= "INSERT INTO ".TABLE_PREFIX."schedules (code, flightnum, deptime, arrtime, daysofweek, price, flighttype, enabled)
   VALUES ('CFC', $pilotid, '00:00', '00:00', '0123456', '0', 'P', '1')";

Be sure to put it before the

DB::query($sql)

Or whatever it is like.

Link to comment
Share on other sites

  • Administrators

Remove the "." from your operator and also single quote the $pilotid

$sql = "INSERT INTO ".TABLE_PREFIX."schedules (code, flightnum, deptime, arrtime, daysofweek, price, flighttype, enabled)
	   VALUES ('CFC', '$pilotid', '00:00', '00:00', '0123456', '0', 'P', '1')";

	DB::query($sql);

Also, be sure you are putting it prior to

return true;

on line 173 and that the schedule code is a valid code in your database. It seems to work on my test install.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...