Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8801167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:45:57+00:00 2026-06-14T00:45:57+00:00

Form on Page: <div> <?php echo form_open(‘add/player’); echo form_label(‘First Name’,’playerFirstName’); echo form_input(‘playerFirstName’,’test’); echo <br

  • 0

Form on Page:

<div>
<?php echo form_open('add/player');
    echo form_label('First Name','playerFirstName');
    echo form_input('playerFirstName','test');
    echo "<br />";
    echo form_label('Last Name','playerLastName');
    echo form_input('playerLastName','test');
    echo "<br />";
    echo form_submit('addPlayer','Add Player');
    echo form_close(); ?>
</div>

Called Controller:

class Add extends CI_Controller
{
    public function index()
    {
        $this->load->view('header');
        $this->load->view('add');
        $this->load->view('footer');
    }

    public function Player()
    {
        if(strtoupper($_SERVER['REQUEST_METHOD']) == 'POST')
        {
            if(basename($_SERVER['HTTP_REFERER']) == basename($_SERVER['PHP_SELF']))
            {
                $this->load->model('players');
                $returnMessage = $this->players->add_player($this->input->post('playerFirstName'), $this->input-post('playerLastName'));
            }
        }
        $this->load->view('header');
        $this->load->view('addplayer');
        $this->load->view('footer');
    }
}

I’m a very green novice when it comes to PHP, CodeIgniter and MySQL (or web coding in general), so if you see any suggestions, please don’t hesitate to make them (though the credit will be given to the one who answers my question, not makes my code work the best). However, as to my question, is there a way to see if a string is within another string? My $returnMessage, if successful will have the word successfully in it. What I want to do is if the player is not added, I want to reload the values from the form and put them back. Here’s where it gets tricky.

The names are saved in table people_names. In the players table, I save the nameid that is associated with that name in the people_names table. In my add_player function, I check to see if the names are in the table, if they aren’t I add them, then I add the player to the players table with the appropriate ids. Because of this, I’m not sure form_validation would be able to be used or not. If it were, please let me know.

So what I want to do is check the $returnMessage and if it doesn’t contain successfully, then I want to add the values back to the fields. However, I’m not finding a function where I can see if a string is inside of another string. I see string compares and substring functions, but no string contains. Any ideas? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:45:58+00:00Added an answer on June 14, 2026 at 12:45 am

    Use native PHP’s strpos: http://php.net/manual/en/function.strpos.php

    Cheers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a html page with a form. The form has Div which gets
Please help! I have some form elements in a div on a page: <div
<form action=/2811457/follow?gsid=3_5bce9b871484d3af90c89f37 method=post> <div> <a href=/2811457/follow?page=2&amp;gsid=3_5bce9b871484d3af90c89f37>next_page</a> &nbsp;<input name=mp type=hidden value=3 /> <input type=text name=page
I have a form page in PHP that reads a DBF, and conditionally converts
I am using php/ajax to submit a form without page refresh. Here are my
Say I have info.php page with user info (id, name, age, etc). On this
I have a page, test.php, with the following code: <html> <body> <form> <script type=text/javascript>
I am using cakephp and creating a form <?php echo $form->create('User', array('action' => 'cancel'));?>
I'm renewing question. For simplify situation I've this script in index.php file <form name=f
I am using php/ajax to submit a form without page refresh. Here are my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.